diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:59:06 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:59:06 +0200 |
commit | 4046be06720932a57a0f49416b0144b2858824d0 (patch) | |
tree | 678c37cab05960f48923a23bb46d9e01be89d35a /library/zstring.cpp | |
parent | 1.19 (diff) | |
download | FreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.tar.gz FreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.tar.bz2 FreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.zip |
2.0
Diffstat (limited to 'library/zstring.cpp')
-rw-r--r-- | library/zstring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/zstring.cpp b/library/zstring.cpp index ddf1fc73..b26ee451 100644 --- a/library/zstring.cpp +++ b/library/zstring.cpp @@ -19,7 +19,7 @@ AllocationCount::~AllocationCount() } -AllocationCount& AllocationCount::getGlobal() +AllocationCount& AllocationCount::getInstance() { static AllocationCount global; return global; @@ -260,7 +260,7 @@ Zstring& Zstring::replace(size_t pos1, size_t n1, const DefaultChar* str, size_t } const size_t newLen = oldLen - n1 + n2; - if (n1 < n2 || descr->refCount > 1) + if (newLen > oldLen || descr->refCount > 1) { //allocate a new string StringDescriptor* newDescr; DefaultChar* newData; @@ -279,7 +279,7 @@ Zstring& Zstring::replace(size_t pos1, size_t n1, const DefaultChar* str, size_t else //overwrite current string: case "n2 == 0" is handled implicitly { memcpy(data + pos1, str, n2 * sizeof(DefaultChar)); - if (n1 > n2) + if (newLen < oldLen) { memmove(data + pos1 + n2, data + pos1 + n1, (oldLen - pos1 - n1) * sizeof(DefaultChar)); data[newLen] = 0; |