You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Add bufSizeAlloc().
This commit is contained in:
@ -81,6 +81,14 @@ bufSize(const Buffer *this)
|
|||||||
return ((const BufferConst *)this)->size;
|
return ((const BufferConst *)this)->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allocated buffer size. This may be different from bufSize() if a limit has been set.
|
||||||
|
__attribute__((always_inline)) static inline size_t
|
||||||
|
bufSizeAlloc(const Buffer *this)
|
||||||
|
{
|
||||||
|
ASSERT_INLINE(this != NULL);
|
||||||
|
return ((const BufferConst *)this)->sizeAlloc;
|
||||||
|
}
|
||||||
|
|
||||||
// Amount of the buffer actually used. This will be updated automatically when possible but if the buffer is modified by using
|
// Amount of the buffer actually used. This will be updated automatically when possible but if the buffer is modified by using
|
||||||
// bufPtr() then the user is responsible for updating used.
|
// bufPtr() then the user is responsible for updating used.
|
||||||
__attribute__((always_inline)) static inline size_t
|
__attribute__((always_inline)) static inline size_t
|
||||||
|
@ -11,7 +11,7 @@ testRun(void)
|
|||||||
FUNCTION_HARNESS_VOID();
|
FUNCTION_HARNESS_VOID();
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("bufNew(), bufNewC, bufNewUseC, bufMove(), bufSize(), bufPtr(), and bufFree()"))
|
if (testBegin("bufNew(), bufNewC, bufNewUseC, bufMove(), bufSize(), bufSizeAlloc(), bufPtr(), and bufFree()"))
|
||||||
{
|
{
|
||||||
Buffer *buffer = NULL;
|
Buffer *buffer = NULL;
|
||||||
|
|
||||||
@ -24,6 +24,7 @@ testRun(void)
|
|||||||
|
|
||||||
TEST_RESULT_PTR(bufPtr(buffer), buffer->buffer, "buffer pointer");
|
TEST_RESULT_PTR(bufPtr(buffer), buffer->buffer, "buffer pointer");
|
||||||
TEST_RESULT_UINT(bufSize(buffer), 256, "buffer size");
|
TEST_RESULT_UINT(bufSize(buffer), 256, "buffer size");
|
||||||
|
TEST_RESULT_UINT(bufSizeAlloc(buffer), 256, "buffer allocation size");
|
||||||
|
|
||||||
TEST_ASSIGN(buffer, bufNewC("TEST-STR", sizeof("TEST-STR") - 1), "new buffer from string");
|
TEST_ASSIGN(buffer, bufNewC("TEST-STR", sizeof("TEST-STR") - 1), "new buffer from string");
|
||||||
TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "TEST-STR", 8) == 0, true, "check buffer");
|
TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "TEST-STR", 8) == 0, true, "check buffer");
|
||||||
|
Reference in New Issue
Block a user