diff options
author | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-23 02:24:34 +0000 |
---|---|---|
committer | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-23 02:24:34 +0000 |
commit | 729ae0b417f65e78ea054b459ce089812da91e36 (patch) | |
tree | 99b53d21c904eccfb0ef2b46fee555796934645c /include/configreader.h | |
parent | c77dbdc9977c0369347244792a910f9ededac2e6 (diff) |
Modified the Set() function in the character array version of ValueContainer to delete the old memory if the value is being reused, and to not allocate memory if there is no string to store.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1464 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'include/configreader.h')
-rw-r--r-- | include/configreader.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/configreader.h b/include/configreader.h index 222195727..6db8f03dc 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -140,6 +140,11 @@ template<> class ValueContainer<char **> : public ValueContainerBase /** Change value to type T of size s */ void Set(const char *newval, size_t s) { + if (*val) delete [] *val; + if (!*newval) { + *val = NULL; + return; + } *val = new char[s]; strlcpy(*val, newval, s); } |