CString can construct from a string_view (#3677)
* CString can construct from a string_view (string_views lack a null terminator) * Update libs/utils/src/CString.cpp Co-authored-by: Mathias Agopian <pixelflinger@gmail.com>
This commit is contained in:
@@ -40,7 +40,8 @@ CString::CString(const char* cstr, size_t length) {
|
||||
p->length = (size_type)length;
|
||||
mCStr = (value_type*)(p + 1);
|
||||
// we don't use memcpy here to avoid a call to libc, the generated code is pretty good.
|
||||
std::uninitialized_copy_n(cstr, length + 1, mCStr);
|
||||
std::uninitialized_copy_n(cstr, length, mCStr);
|
||||
mCStr[length] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user