1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Rename strNew() to strNewZ() and add parameter-less strNew().

Replace all instances of strNew("") with strNew() and use strNewZ() for non-empty zero-terminated strings. Besides saving a useless parameter, this will allow smarter memory allocation in a future commit by signaling intent, in general, to append or not.

In the tests use STRDEF() or VARSTRDEF() where more appropriate rather than blindly replacing with strNewZ(). Also replace strLstAdd() with strLstAddZ() where appropriate for the same reason.
This commit is contained in:
David Steele
2021-05-21 17:36:43 -04:00
parent 68faf1482a
commit aed3d468a1
96 changed files with 1690 additions and 1671 deletions

View File

@ -104,7 +104,7 @@ pgClientEscape(const String *string)
ASSERT(string != NULL);
String *result = strNew("'");
String *result = strNewZ("'");
// Iterate all characters in the string
for (unsigned stringIdx = 0; stringIdx < strSize(string); stringIdx++)
@ -158,7 +158,7 @@ pgClientOpen(PgClient *this)
{
THROW_FMT(
DbConnectError, "unable to connect to '%s': %s", strZ(connInfo),
strZ(strTrim(strNew(PQerrorMessage(this->connection)))));
strZ(strTrim(strNewZ(PQerrorMessage(this->connection)))));
}
// Set notice and warning processor
@ -191,7 +191,7 @@ pgClientQuery(PgClient *this, const String *query)
{
THROW_FMT(
DbQueryError, "unable to send query '%s': %s", strZ(query),
strZ(strTrim(strNew(PQerrorMessage(this->connection)))));
strZ(strTrim(strNewZ(PQerrorMessage(this->connection)))));
}
// Wait for a result
@ -219,7 +219,7 @@ pgClientQuery(PgClient *this, const String *query)
char error[256];
if (!PQcancel(cancel, error, sizeof(error)))
THROW_FMT(DbQueryError, "unable to cancel query '%s': %s", strZ(query), strZ(strTrim(strNew(error))));
THROW_FMT(DbQueryError, "unable to cancel query '%s': %s", strZ(query), strZ(strTrim(strNewZ(error))));
}
FINALLY()
{
@ -247,7 +247,7 @@ pgClientQuery(PgClient *this, const String *query)
{
THROW_FMT(
DbQueryError, "unable to execute query '%s': %s", strZ(query),
strZ(strTrim(strNew(PQresultErrorMessage(pgResult)))));
strZ(strTrim(strNewZ(PQresultErrorMessage(pgResult)))));
}
// Fetch row and column values