1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Avoid calling strlen() twice in bufNewZ().

This commit is contained in:
Stephen Frost 2018-09-30 11:45:37 +01:00 committed by David Steele
parent 5404628148
commit 3be9f2dee7
2 changed files with 7 additions and 2 deletions

View File

@ -107,6 +107,11 @@
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-contributor id="stephen.frost"/>
</release-item-contributor-list>
<p>Add <code>bufNewZ()</code> and <code>bufHex()</code>to <code>Buffer</code> object.</p>
</release-item>

View File

@ -101,9 +101,9 @@ bufNewZ(const char *string)
FUNCTION_TEST_ASSERT(string != NULL);
FUNCTION_TEST_END();
// Create object and copy string
// Create a new buffer and then copy the string into it.
Buffer *this = bufNew(strlen(string));
memcpy(this->buffer, string, strlen(string));
memcpy(this->buffer, string, this->size);
this->used = this->size;
FUNCTION_TEST_RESULT(BUFFER, this);