From 4e11583205327ce9d65c744473baff28d54979b3 Mon Sep 17 00:00:00 2001 From: "Naram Qashat cyberbotx@cyberbotx.com" Date: Sun, 5 Oct 2008 03:01:18 +0000 Subject: Fix problems with using ValueContainerChar by creating a specialized template for ValueContainer. Note: The solution uses new to allocate memory for the variable, we'll have to look into deleting the memory at shutdown, or replacing the char * variables with std::string. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1424 5417fbe8-f217-4b02-8779-1006273d7864 --- include/configreader.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include') diff --git a/include/configreader.h b/include/configreader.h index 2a40fd8ef..222195727 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -119,6 +119,32 @@ template class ValueContainer : public ValueContainerBase } }; +/** This a specific version of ValueContainer to handle character arrays specially + */ +template<> class ValueContainer : public ValueContainerBase +{ + /** Contained item */ + char **val; + public: + /** Initialize with nothing */ + ValueContainer() : ValueContainerBase(), val(NULL) { } + /** Initialize with a value of type T */ + ValueContainer(char **Val) : ValueContainerBase(), val(Val) { } + /** Initialize with a copy */ + ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } + ValueContainer &operator=(const ValueContainer &Val) + { + val = Val.val; + return *this; + } + /** Change value to type T of size s */ + void Set(const char *newval, size_t s) + { + *val = new char[s]; + strlcpy(*val, newval, s); + } +}; + /** This a specific version of ValueContainer to handle std::string specially */ template<> class ValueContainer : public ValueContainerBase -- cgit