mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Add constant for maximum buffer sizes required by cvt*() functions.
Also update Variant to use cvt*() in all cases. Variant was written before these functions were available and not all cases were updated.
This commit is contained in:
parent
f5739051eb
commit
f100ea0ff4
@ -37,6 +37,10 @@
|
||||
<p><code>varNewKv()</code> accepts a <code>KeyValue</code> object rather than creating one.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add constant for maximum buffer sizes required by <code>cvt*()</code> functions.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Add <id>true</id> and <id>false</id> <code>String</code> constants.</p>
|
||||
</release-item>
|
||||
|
@ -298,7 +298,7 @@ tlsClientOpen(TlsClient *this)
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
// Convert the port to a zero-terminated string for use with getaddrinfo()
|
||||
char port[32];
|
||||
char port[CVT_BASE10_BUFFER_SIZE];
|
||||
cvtUIntToZ(this->port, port, sizeof(port));
|
||||
|
||||
// Get an address for the host. We are only going to try the first address returned.
|
||||
|
@ -7,6 +7,12 @@ Convert Base Data Types
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Required buffer sizes
|
||||
***********************************************************************************************************************************/
|
||||
#define CVT_BOOL_BUFFER_SIZE 6
|
||||
#define CVT_BASE10_BUFFER_SIZE 64
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -1080,27 +1080,22 @@ varStrForce(const Variant *this)
|
||||
{
|
||||
case varTypeBool:
|
||||
{
|
||||
char working[6];
|
||||
|
||||
cvtBoolToZ(varBool(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
|
||||
result = strNew(cvtBoolToConstZ(varBool(this)));
|
||||
break;
|
||||
}
|
||||
|
||||
case varTypeDouble:
|
||||
{
|
||||
char working[64];
|
||||
char working[CVT_BASE10_BUFFER_SIZE];
|
||||
|
||||
cvtDoubleToZ(varDbl(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case varTypeInt:
|
||||
{
|
||||
char working[64];
|
||||
char working[CVT_BASE10_BUFFER_SIZE];
|
||||
|
||||
cvtIntToZ(varInt(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
@ -1109,7 +1104,7 @@ varStrForce(const Variant *this)
|
||||
|
||||
case varTypeInt64:
|
||||
{
|
||||
char working[64];
|
||||
char working[CVT_BASE10_BUFFER_SIZE];
|
||||
|
||||
cvtInt64ToZ(varInt64(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
@ -1124,13 +1119,19 @@ varStrForce(const Variant *this)
|
||||
|
||||
case varTypeUInt:
|
||||
{
|
||||
result = strNewFmt("%u", varUInt(this));
|
||||
char working[CVT_BASE10_BUFFER_SIZE];
|
||||
|
||||
cvtUIntToZ(varUInt(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
break;
|
||||
}
|
||||
|
||||
case varTypeUInt64:
|
||||
{
|
||||
result = strNewFmt("%" PRIu64, varUInt64(this));
|
||||
char working[CVT_BASE10_BUFFER_SIZE];
|
||||
|
||||
cvtUInt64ToZ(varUInt64(this), working, sizeof(working));
|
||||
result = strNew(working);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user