summaryrefslogtreecommitdiff
path: root/library/zstring.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:59:06 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:59:06 +0200
commit4046be06720932a57a0f49416b0144b2858824d0 (patch)
tree678c37cab05960f48923a23bb46d9e01be89d35a /library/zstring.cpp
parent1.19 (diff)
downloadFreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.tar.gz
FreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.tar.bz2
FreeFileSync-4046be06720932a57a0f49416b0144b2858824d0.zip
2.0
Diffstat (limited to 'library/zstring.cpp')
-rw-r--r--library/zstring.cpp6
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;
bgstack15