diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2011-08-22 11:53:41 +0000 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2011-08-22 11:53:41 +0000 |
commit | e8fb7cdda152fd4eb26f63dc82f3c96063354ceb (patch) | |
tree | b0c7085e0226bd78eb53a8f2e399e5e769bafc68 | |
parent | 5bff2d46d7f311971862d2b1ca3cd47f8e342b5f (diff) |
TEngineModuleBase::GetStrValue: use more efficient std::string::assign()
Copying the "char *" into std::string is more efficient with
std::string::assign() than with the assignment operator because the
already known string length can be reused.
As a side effect it also avoids a valgrind warning about reading one
byte past the end of the allocated string buffer inside char_traits.h
line 261. Probably was cause by an optimized strlen() variant inside
std::string.
-rwxr-xr-x | src/sysync_SDK/Sources/enginemodulebase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sysync_SDK/Sources/enginemodulebase.cpp b/src/sysync_SDK/Sources/enginemodulebase.cpp index 9fd88a5..64ace6c 100755 --- a/src/sysync_SDK/Sources/enginemodulebase.cpp +++ b/src/sysync_SDK/Sources/enginemodulebase.cpp @@ -118,7 +118,7 @@ TSyError TEngineModuleBase::GetStrValue( KeyH aKeyH, cAppCharP aValName, string err= GetValue( aKeyH, aValName, VALTYPE_TEXT, f, txtSize+1, txtSize ); // no error anymore } // if - aText= f; // assign it + aText.assign(f, txtSize); // assign it if (tooShort) free( f ); // and deallocate again, if used dynamically |