1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-04-11 11:22:01 +02:00

Simplify object creation with OBJ_NEW_BEGIN() macro.

Eliminate the boilerplate of declaring this and assigning memory to it, which is the same for the vast majority of object creations.

Keep the old version of the macro as OBJ_NEW_BASE_BEGIN() for a few exceptions in the core code and (mostly) in the tests.
This commit is contained in:
David Steele 2023-03-28 15:05:18 +06:00
parent 91f9301b9d
commit b111599bad
103 changed files with 77 additions and 506 deletions

View File

@ -132,12 +132,8 @@ myObjNew(unsigned int myData, const String *secretName)
ASSERT(secretName != NULL || myData > 0); // Development-only assertions (will be compiled out of production code)
MyObj *this = NULL; // Declare the object in the parent memory context: it will live only as long as the parent
OBJ_NEW_BEGIN(MyObj) // Create a long lasting memory context with the name of the object
{
this = OBJ_NEW_ALLOC(); // Allocate the memory required by the object
*this = (MyObj) // Initialize the object
{
.pub =

View File

@ -238,12 +238,8 @@ myObjNew(unsigned int myData, const String *secretName)
ASSERT(secretName != NULL || myData > 0); // Development-only assertions (will be compiled out of production code)
MyObj *this = NULL; // Declare the object in the parent memory context: it will live only as long as the parent
OBJ_NEW_BEGIN(MyObj) // Create a long lasting memory context with the name of the object
{
this = OBJ_NEW_ALLOC(); // Allocate the memory required by the object
*this = (MyObj) // Initialize the object
{
.pub =

View File

@ -47,12 +47,8 @@ yamlNew(const Buffer *const buffer)
FUNCTION_TEST_PARAM(BUFFER, buffer);
FUNCTION_TEST_END();
Yaml *this = NULL;
OBJ_NEW_BEGIN(Yaml, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (Yaml){{0}}; // Extra braces are required for older gcc versions
// Initialize parser context

View File

@ -388,12 +388,8 @@ blockIncrNew(
FUNCTION_LOG_PARAM(IO_FILTER, encrypt);
FUNCTION_LOG_END();
BlockIncr *this = NULL;
OBJ_NEW_BEGIN(BlockIncr, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (BlockIncr)
{
.superBlockSize = (superBlockSize / blockSize + (superBlockSize % blockSize == 0 ? 0 : 1)) * blockSize,

View File

@ -231,12 +231,8 @@ pageChecksumNew(const unsigned int segmentNo, const unsigned int segmentPageTota
FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_END();
PageChecksum *this;
OBJ_NEW_BEGIN(PageChecksum, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (PageChecksum)
{
.segmentPageTotal = segmentPageTotal,

View File

@ -137,12 +137,8 @@ blockChecksumNew(const size_t blockSize, const size_t checksumSize)
ASSERT(checksumSize != 0);
// Allocate memory to hold process state
BlockChecksum *this;
OBJ_NEW_BEGIN(BlockChecksum, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (BlockChecksum)
{
.blockSize = blockSize,

View File

@ -73,13 +73,8 @@ blockDeltaNew(
ASSERT(blockSize > 0);
ASSERT(cipherType == cipherTypeNone || cipherPass != NULL);
BlockDelta *this = NULL;
OBJ_NEW_BEGIN(BlockDelta, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (BlockDelta)
{
.pub =

View File

@ -166,12 +166,8 @@ bz2CompressNew(const int level, const bool raw)
ASSERT(level >= BZ2_COMPRESS_LEVEL_MIN && level <= BZ2_COMPRESS_LEVEL_MAX);
Bz2Compress *this;
OBJ_NEW_BEGIN(Bz2Compress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Bz2Compress)
{
.stream = {.bzalloc = NULL},

View File

@ -150,12 +150,8 @@ bz2DecompressNew(const bool raw)
(void)raw; // Raw unsupported
FUNCTION_LOG_END();
Bz2Decompress *this;
OBJ_NEW_BEGIN(Bz2Decompress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Bz2Decompress)
{
.stream = {.bzalloc = NULL},

View File

@ -173,12 +173,8 @@ gzCompressNew(const int level, const bool raw)
ASSERT(level >= GZ_COMPRESS_LEVEL_MIN && level <= GZ_COMPRESS_LEVEL_MAX);
GzCompress *this;
OBJ_NEW_BEGIN(GzCompress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (GzCompress)
{
.stream = {.zalloc = NULL},

View File

@ -152,12 +152,8 @@ gzDecompressNew(const bool raw)
FUNCTION_LOG_PARAM(BOOL, raw);
FUNCTION_LOG_END();
GzDecompress *this;
OBJ_NEW_BEGIN(GzDecompress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (GzDecompress)
{
.stream = {.zalloc = NULL},

View File

@ -252,12 +252,8 @@ lz4CompressNew(const int level, const bool raw)
ASSERT(level >= LZ4_COMPRESS_LEVEL_MIN && level <= LZ4_COMPRESS_LEVEL_MAX);
Lz4Compress *this;
OBJ_NEW_BEGIN(Lz4Compress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Lz4Compress)
{
.prefs =

View File

@ -163,11 +163,8 @@ lz4DecompressNew(const bool raw)
(void)raw; // Not required for decompress
FUNCTION_LOG_END();
Lz4Decompress *this;
OBJ_NEW_BEGIN(Lz4Decompress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Lz4Decompress){0};
// Create lz4 context

View File

@ -173,12 +173,8 @@ zstCompressNew(const int level, const bool raw)
ASSERT(level >= ZST_COMPRESS_LEVEL_MIN && level <= ZST_COMPRESS_LEVEL_MAX);
ZstCompress *this;
OBJ_NEW_BEGIN(ZstCompress, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (ZstCompress)
{
.context = ZSTD_createCStream(),

View File

@ -162,12 +162,8 @@ zstDecompressNew(const bool raw)
(void)raw; // Raw unsupported
FUNCTION_LOG_END();
ZstDecompress *this;
OBJ_NEW_BEGIN(ZstDecompress, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (ZstDecompress)
{
.context = ZSTD_createDStream(),

View File

@ -423,13 +423,8 @@ cipherBlockNew(const CipherMode mode, const CipherType cipherType, const Buffer
if (!digest)
THROW_FMT(AssertError, "unable to load digest '%s'", strZ(param.digest));
// Allocate memory to hold process state
CipherBlock *this;
OBJ_NEW_BEGIN(CipherBlock, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (CipherBlock)
{
.mode = mode,

View File

@ -179,12 +179,8 @@ cryptoHashNew(const HashType type)
// Init crypto subsystem
cryptoInit();
// Allocate memory to hold process state
CryptoHash *this;
OBJ_NEW_BEGIN(CryptoHash, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (CryptoHash){0};
// Use local MD5 implementation since FIPS-enabled systems do not allow MD5. This is a bit misguided since there are valid

View File

@ -116,12 +116,8 @@ xxHashNew(const size_t size)
ASSERT(size >= 1 && size <= XX_HASH_SIZE_MAX);
// Allocate memory to hold process state
XxHash *this;
OBJ_NEW_BEGIN(XxHash, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (XxHash){.size = size};
this->state = XXH3_createState();

View File

@ -125,12 +125,8 @@ execNew(const String *command, const StringList *param, const String *name, Time
ASSERT(name != NULL);
ASSERT(timeout > 0);
Exec *this = NULL;
OBJ_NEW_BEGIN(Exec, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Exec)
{
.command = strDup(command),

View File

@ -35,12 +35,8 @@ iniNew(IoRead *const read, const IniNewParam param)
FUNCTION_LOG_PARAM(BOOL, param.store);
FUNCTION_LOG_END();
Ini *this = NULL;
OBJ_NEW_BEGIN(Ini, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (Ini)
{
.read = read,

View File

@ -92,12 +92,8 @@ ioBufferReadNew(const Buffer *const buffer)
ASSERT(buffer != NULL);
IoBufferRead *this;
OBJ_NEW_BEGIN(IoBufferRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoBufferRead)
{
.read = buffer,

View File

@ -56,12 +56,8 @@ ioBufferWriteNew(Buffer *const buffer)
ASSERT(buffer != NULL);
IoBufferWrite *this;
OBJ_NEW_BEGIN(IoBufferWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoBufferWrite)
{
.write = buffer,

View File

@ -154,12 +154,8 @@ ioChunkedReadNew(IoRead *const read)
ASSERT(read != NULL);
IoChunkedRead *this;
OBJ_NEW_BEGIN(IoChunkedRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoChunkedRead)
{
.read = read,

View File

@ -31,12 +31,8 @@ ioClientNew(void *const driver, const IoClientInterface *const interface)
ASSERT(interface->open != NULL);
ASSERT(interface->toLog != NULL);
IoClient *this;
OBJ_NEW_BEGIN(IoClient, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoClient)
{
.pub =

View File

@ -154,12 +154,8 @@ ioFdReadNew(const String *const name, const int fd, const TimeMSec timeout)
ASSERT(fd != -1);
IoFdRead *this;
OBJ_NEW_BEGIN(IoFdRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoFdRead)
{
.name = strDup(name),

View File

@ -110,12 +110,8 @@ ioFdWriteNew(const String *const name, const int fd, const TimeMSec timeout)
FUNCTION_LOG_PARAM(TIME_MSEC, timeout);
FUNCTION_LOG_END();
IoFdWrite *this;
OBJ_NEW_BEGIN(IoFdWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoFdWrite)
{
.name = strDup(name),

View File

@ -108,11 +108,8 @@ ioBufferNew(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
IoBuffer *this;
OBJ_NEW_BEGIN(IoBuffer)
{
this = OBJ_NEW_ALLOC();
*this = (IoBuffer){0};
}
OBJ_NEW_END();

View File

@ -149,11 +149,8 @@ ioChunkNew(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
IoChunk *this;
OBJ_NEW_BEGIN(IoChunk)
{
this = OBJ_NEW_ALLOC();
*this = (IoChunk){0};
}
OBJ_NEW_END();

View File

@ -39,12 +39,8 @@ ioFilterNew(const StringId type, void *const driver, Pack *const paramList, cons
// If the filter does not produce output then it should produce a result
ASSERT(interface.in == NULL || (interface.result != NULL && interface.done == NULL && interface.inputSame == NULL));
IoFilter *this;
OBJ_NEW_BEGIN(IoFilter, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoFilter)
{
.pub =

View File

@ -61,12 +61,8 @@ ioFilterGroupNew(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
IoFilterGroup *this = NULL;
OBJ_NEW_BEGIN(IoFilterGroup, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoFilterGroup)
{
.pub =

View File

@ -52,11 +52,8 @@ ioSinkNew(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
IoSink *this;
OBJ_NEW_BEGIN(IoSink)
{
this = OBJ_NEW_ALLOC();
}
OBJ_NEW_END();

View File

@ -91,11 +91,8 @@ ioSizeNew(void)
{
FUNCTION_LOG_VOID(logLevelTrace);
IoSize *this;
OBJ_NEW_BEGIN(IoSize)
{
this = OBJ_NEW_ALLOC();
*this = (IoSize){0};
}
OBJ_NEW_END();

View File

@ -41,12 +41,8 @@ httpClientNew(IoClient *ioClient, TimeMSec timeout)
ASSERT(ioClient != NULL);
HttpClient *this = NULL;
OBJ_NEW_BEGIN(HttpClient, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (HttpClient)
{
.pub =

View File

@ -23,13 +23,8 @@ httpHeaderNew(const StringList *redactList)
{
FUNCTION_TEST_VOID();
HttpHeader *this = NULL;
OBJ_NEW_BEGIN(HttpHeader, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (HttpHeader)
{
.redactList = strLstDup(redactList),
@ -50,23 +45,18 @@ httpHeaderDup(const HttpHeader *header, const StringList *redactList)
FUNCTION_TEST_PARAM(STRING_LIST, redactList);
FUNCTION_TEST_END();
HttpHeader *this = NULL;
if (header == NULL)
FUNCTION_TEST_RETURN(HTTP_HEADER, NULL);
if (header != NULL)
OBJ_NEW_BEGIN(HttpHeader, .childQty = MEM_CONTEXT_QTY_MAX)
{
OBJ_NEW_BEGIN(HttpHeader, .childQty = MEM_CONTEXT_QTY_MAX)
*this = (HttpHeader)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (HttpHeader)
{
.redactList = redactList == NULL ? strLstDup(header->redactList) : strLstDup(redactList),
.kv = kvDup(header->kv),
};
}
OBJ_NEW_END();
.redactList = redactList == NULL ? strLstDup(header->redactList) : strLstDup(redactList),
.kv = kvDup(header->kv),
};
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(HTTP_HEADER, this);
}

View File

@ -25,13 +25,8 @@ httpQueryNew(HttpQueryNewParam param)
FUNCTION_TEST_PARAM(STRING_LIST, param.redactList);
FUNCTION_TEST_END();
HttpQuery *this = NULL;
OBJ_NEW_BEGIN(HttpQuery, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (HttpQuery)
{
.kv = kvNew(),
@ -53,12 +48,8 @@ httpQueryNewStr(const String *query)
ASSERT(query != NULL);
HttpQuery *this = NULL;
OBJ_NEW_BEGIN(HttpQuery, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (HttpQuery)
{
.kv = kvNew(),
@ -104,23 +95,18 @@ httpQueryDup(const HttpQuery *query, HttpQueryDupParam param)
FUNCTION_TEST_PARAM(STRING_LIST, param.redactList);
FUNCTION_TEST_END();
HttpQuery *this = NULL;
if (query == NULL)
FUNCTION_TEST_RETURN(HTTP_QUERY, NULL);
if (query != NULL)
OBJ_NEW_BEGIN(HttpQuery, .childQty = MEM_CONTEXT_QTY_MAX)
{
OBJ_NEW_BEGIN(HttpQuery, .childQty = MEM_CONTEXT_QTY_MAX)
*this = (HttpQuery)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (HttpQuery)
{
.kv = kvDup(query->kv),
.redactList = param.redactList != NULL ? strLstDup(param.redactList) : strLstDup(query->redactList),
};
}
OBJ_NEW_END();
.kv = kvDup(query->kv),
.redactList = param.redactList != NULL ? strLstDup(param.redactList) : strLstDup(query->redactList),
};
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(HTTP_QUERY, this);
}

View File

@ -190,12 +190,8 @@ httpRequestNew(HttpClient *client, const String *verb, const String *path, HttpR
ASSERT(verb != NULL);
ASSERT(path != NULL);
HttpRequest *this = NULL;
OBJ_NEW_BEGIN(HttpRequest, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (HttpRequest)
{
.pub =

View File

@ -218,12 +218,8 @@ httpResponseNew(HttpSession *session, const String *verb, bool contentCache)
ASSERT(session != NULL);
ASSERT(verb != NULL);
HttpResponse *this = NULL;
OBJ_NEW_BEGIN(HttpResponse, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (HttpResponse)
{
.pub =

View File

@ -29,12 +29,8 @@ httpSessionNew(HttpClient *httpClient, IoSession *ioSession)
ASSERT(httpClient != NULL);
ASSERT(ioSession != NULL);
HttpSession *this = NULL;
OBJ_NEW_BEGIN(HttpSession, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (HttpSession)
{
.httpClient = httpClient,

View File

@ -60,13 +60,8 @@ httpUrlNewParse(const String *const url, HttpUrlNewParseParam param)
ASSERT(url != NULL);
HttpUrl *this = NULL;
OBJ_NEW_BEGIN(HttpUrl, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (HttpUrl)
{
.pub =

View File

@ -33,12 +33,8 @@ ioReadNew(void *const driver, const IoReadInterface interface)
ASSERT(driver != NULL);
ASSERT(interface.read != NULL);
IoRead *this = NULL;
OBJ_NEW_BEGIN(IoRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoRead)
{
.pub =

View File

@ -32,12 +32,8 @@ ioServerNew(void *const driver, const IoServerInterface *const interface)
ASSERT(interface->accept != NULL);
ASSERT(interface->toLog != NULL);
IoServer *this;
OBJ_NEW_BEGIN(IoServer, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoServer)
{
.pub =

View File

@ -33,12 +33,8 @@ ioSessionNew(void *const driver, const IoSessionInterface *const interface)
ASSERT(interface->role != NULL);
ASSERT(interface->toLog != NULL);
IoSession *this;
OBJ_NEW_BEGIN(IoSession, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoSession)
{
.pub =

View File

@ -170,12 +170,8 @@ sckClientNew(const String *const host, const unsigned int port, const TimeMSec t
ASSERT(host != NULL);
SocketClient *this;
OBJ_NEW_BEGIN(SocketClient, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (SocketClient)
{
.host = strDup(host),

View File

@ -153,12 +153,8 @@ sckServerNew(const String *const address, const unsigned int port, const TimeMSe
ASSERT(address != NULL);
ASSERT(port > 0);
SocketServer *this;
OBJ_NEW_BEGIN(SocketServer, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (SocketServer)
{
.address = strDup(address),

View File

@ -177,11 +177,8 @@ sckSessionNew(const IoSessionRole role, const int fd, const String *const host,
ASSERT(fd != -1);
ASSERT(host != NULL);
SocketSession *this;
OBJ_NEW_BEGIN(SocketSession, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
String *const name = strNewFmt("%s:%u", strZ(host), port);
*this = (SocketSession)

View File

@ -366,15 +366,11 @@ tlsClientNew(
ASSERT(ioClient != NULL);
TlsClient *this;
OBJ_NEW_BEGIN(TlsClient, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (TlsClient)
{
.ioClient = ioClientMove(ioClient, MEM_CONTEXT_NEW()),
.ioClient = ioClientMove(ioClient, objMemContext(this)),
.host = strDup(host),
.timeoutConnect = timeoutConnect,
.timeoutSession = timeoutSession,

View File

@ -294,12 +294,8 @@ tlsServerNew(
ASSERT(keyFile != NULL);
ASSERT(certFile != NULL);
TlsServer *this;
OBJ_NEW_BEGIN(TlsServer, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (TlsServer)
{
.host = strDup(host),

View File

@ -361,16 +361,12 @@ tlsSessionNew(SSL *const session, IoSession *const ioSession, const TimeMSec tim
ASSERT(session != NULL);
ASSERT(ioSession != NULL);
TlsSession *this;
OBJ_NEW_BEGIN(TlsSession, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (TlsSession)
{
.session = session,
.ioSession = ioSessionMove(ioSession, MEM_CONTEXT_NEW()),
.ioSession = ioSessionMove(ioSession, objMemContext(this)),
.timeout = timeout,
.shutdownOnClose = true,
};

View File

@ -39,12 +39,8 @@ ioWriteNew(void *const driver, const IoWriteInterface interface)
ASSERT(driver != NULL);
ASSERT(interface.write != NULL);
IoWrite *this;
OBJ_NEW_BEGIN(IoWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoWrite)
{
.pub =

View File

@ -70,11 +70,8 @@ regExpNew(const String *expression)
ASSERT(expression != NULL);
RegExp *this = NULL;
OBJ_NEW_BEGIN(RegExp, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (RegExp){{0}}; // Extra braces are required for older gcc versions
// Compile the regexp and process errors

View File

@ -24,12 +24,8 @@ blbNew(void)
{
FUNCTION_TEST_VOID();
Blob *this = NULL;
OBJ_NEW_BEGIN(Blob, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (Blob)
{
.block = memNew(BLOB_BLOCK_SIZE),

View File

@ -37,13 +37,8 @@ bufNew(size_t size)
FUNCTION_TEST_PARAM(SIZE, size);
FUNCTION_TEST_END();
Buffer *this = NULL;
OBJ_NEW_BEGIN(Buffer, .allocQty = 1)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (Buffer)
{
.pub =

View File

@ -90,12 +90,8 @@ jsonReadNew(const String *const json)
FUNCTION_TEST_PARAM(STRING, json);
FUNCTION_TEST_END();
JsonRead *this = NULL;
OBJ_NEW_BEGIN(JsonRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (JsonRead)
{
.json = strZ(json),
@ -1317,12 +1313,8 @@ jsonWriteNew(JsonWriteNewParam param)
FUNCTION_TEST_PARAM(STRING, param.json);
FUNCTION_TEST_END();
JsonWrite *this = NULL;
OBJ_NEW_BEGIN(JsonWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (JsonWrite)
{
.json = param.json == NULL ? strNew() : param.json,

View File

@ -34,13 +34,8 @@ kvNew(void)
{
FUNCTION_TEST_VOID();
KeyValue *this = NULL;
OBJ_NEW_BEGIN(KeyValue, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Allocate state and set context
this = OBJ_NEW_ALLOC();
*this = (KeyValue)
{
.pub =

View File

@ -33,13 +33,8 @@ lstNew(size_t itemSize, ListParam param)
FUNCTION_TEST_PARAM(FUNCTIONP, param.comparator);
FUNCTION_TEST_END();
List *this = NULL;
OBJ_NEW_BEGIN(List, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (List)
{
.itemSize = itemSize,

View File

@ -13,25 +13,33 @@ These macros and functions implement common object functionality.
/***********************************************************************************************************************************
Create a new object
This is a thin wrapper on MEM_CONTEXT_NEW_*() to do object specific initialization. The general pattern
for a new object is:
MyObj *this = NULL;
This is a thin wrapper on MEM_CONTEXT_NEW_*() to do object specific initialization. The general pattern for a new object is:
OBJ_NEW_BEGIN(MyObj)
{
this = OBJ_NEW_ALLOC();
*this = (MyObj)
{
.data = ...
};
}
OBJ_NEW_END();
The this variable is variable is automatically created with the specified type. The BASE and EXTRA variants are available when a
custom variable must be used or different amount of memory must be allocated.
***********************************************************************************************************************************/
#define OBJ_NEW_EXTRA_BEGIN(type, extra, ...) \
#define OBJ_NEW_BASE_EXTRA_BEGIN(type, extra, ...) \
MEM_CONTEXT_NEW_BEGIN(type, .allocExtra = extra, __VA_ARGS__)
#define OBJ_NEW_EXTRA_BEGIN(type, extra, ...) \
memContextSwitch(memContextNewP(STRINGIFY(type), .allocExtra = extra, __VA_ARGS__)); \
type *const this = OBJ_NEW_ALLOC(); \
\
do \
{
#define OBJ_NEW_BASE_BEGIN(type, ...) \
OBJ_NEW_BASE_EXTRA_BEGIN(type, sizeof(type), __VA_ARGS__)
#define OBJ_NEW_BEGIN(type, ...) \
OBJ_NEW_EXTRA_BEGIN(type, sizeof(type), __VA_ARGS__)

View File

@ -334,12 +334,8 @@ pckReadNewInternal(void)
{
FUNCTION_TEST_VOID();
PackRead *this = NULL;
OBJ_NEW_BEGIN(PackRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (PackRead)
{
.tagStack = {.bottom = {.typeMap = pckTypeMapObj}},
@ -1257,12 +1253,8 @@ pckWriteNewInternal(void)
{
FUNCTION_TEST_VOID();
PackWrite *this = NULL;
OBJ_NEW_BEGIN(PackWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (PackWrite)
{
.tagStack = {.bottom = {.typeMap = pckTypeMapObj}},

View File

@ -74,12 +74,8 @@ strNew(void)
{
FUNCTION_TEST_VOID();
String *this = NULL;
OBJ_NEW_BEGIN(String, .allocQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (String)
{
.pub =
@ -106,8 +102,6 @@ strNewFixed(const size_t size)
CHECK_SIZE(size);
String *this = NULL;
// If the string is larger than the extra allowed with a mem context then allocate the buffer separately
size_t allocExtra = sizeof(String) + size + 1;
@ -115,8 +109,6 @@ strNewFixed(const size_t size)
{
OBJ_NEW_BEGIN(String, .allocQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (String)
{
.pub =
@ -133,8 +125,6 @@ strNewFixed(const size_t size)
OBJ_NEW_EXTRA_BEGIN(String, (uint16_t)(allocExtra))
{
this = OBJ_NEW_ALLOC();
*this = (String)
{
.pub =

View File

@ -207,12 +207,8 @@ varNewBool(bool data)
FUNCTION_TEST_PARAM(BOOL, data);
FUNCTION_TEST_END();
VariantBool *this = NULL;
OBJ_NEW_BEGIN(VariantBool)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantBool);
*this = (VariantBool)
{
.pub =
@ -224,7 +220,7 @@ varNewBool(bool data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantBool));
}
/**********************************************************************************************************************************/
@ -316,12 +312,8 @@ varNewInt(int data)
FUNCTION_TEST_PARAM(INT, data);
FUNCTION_TEST_END();
VariantInt *this = NULL;
OBJ_NEW_BEGIN(VariantInt)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantInt);
*this = (VariantInt)
{
.pub =
@ -333,7 +325,7 @@ varNewInt(int data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantInt));
}
/**********************************************************************************************************************************/
@ -432,12 +424,8 @@ varNewInt64(int64_t data)
FUNCTION_TEST_PARAM(INT64, data);
FUNCTION_TEST_END();
VariantInt64 *this = NULL;
OBJ_NEW_BEGIN(VariantInt64)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantInt64);
*this = (VariantInt64)
{
.pub =
@ -449,7 +437,7 @@ varNewInt64(int64_t data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantInt64));
}
/**********************************************************************************************************************************/
@ -532,12 +520,8 @@ varNewUInt(unsigned int data)
FUNCTION_TEST_PARAM(UINT, data);
FUNCTION_TEST_END();
VariantUInt *this = NULL;
OBJ_NEW_BEGIN(VariantUInt)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantUInt);
*this = (VariantUInt)
{
.pub =
@ -549,7 +533,7 @@ varNewUInt(unsigned int data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantUInt));
}
/**********************************************************************************************************************************/
@ -657,12 +641,8 @@ varNewUInt64(uint64_t data)
FUNCTION_TEST_PARAM(UINT64, data);
FUNCTION_TEST_END();
VariantUInt64 *this = NULL;
OBJ_NEW_BEGIN(VariantUInt64)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantUInt64);
*this = (VariantUInt64)
{
.pub =
@ -674,7 +654,7 @@ varNewUInt64(uint64_t data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantUInt64));
}
/**********************************************************************************************************************************/
@ -769,12 +749,8 @@ varNewKv(KeyValue *data)
FUNCTION_TEST_PARAM(KEY_VALUE, data);
FUNCTION_TEST_END();
VariantKeyValue *this = NULL;
OBJ_NEW_BEGIN(VariantKeyValue, .childQty = 1)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantKeyValue);
*this = (VariantKeyValue)
{
.type = varTypeKeyValue,
@ -785,7 +761,7 @@ varNewKv(KeyValue *data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantKeyValue));
}
/**********************************************************************************************************************************/
@ -815,8 +791,6 @@ varNewStr(const String *data)
FUNCTION_TEST_PARAM(STRING, data);
FUNCTION_TEST_END();
VariantString *this = NULL;
// If the variant is larger than the extra allowed with a mem context then allocate the buffer separately
size_t allocExtra = sizeof(VariantString) + (data != NULL ? sizeof(StringPub) + strSize(data) + 1 : 0);
@ -826,8 +800,6 @@ varNewStr(const String *data)
OBJ_NEW_BEGIN(VariantString, .childQty = 1)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantString);
*this = (VariantString)
{
.pub =
@ -839,13 +811,11 @@ varNewStr(const String *data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantString));
}
OBJ_NEW_EXTRA_BEGIN(VariantString, (uint16_t)(allocExtra))
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantString);
*this = (VariantString)
{
.pub =
@ -874,7 +844,7 @@ varNewStr(const String *data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantString));
}
FN_EXTERN Variant *
@ -978,12 +948,8 @@ varNewVarLst(const VariantList *data)
FUNCTION_TEST_PARAM(VARIANT_LIST, data);
FUNCTION_TEST_END();
VariantVariantList *this = NULL;
OBJ_NEW_BEGIN(VariantVariantList, .childQty = 1)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), Variant::VariantVariantList);
*this = (VariantVariantList)
{
.type = varTypeVariantList,
@ -994,7 +960,7 @@ varNewVarLst(const VariantList *data)
}
OBJ_NEW_END();
FUNCTION_TEST_RETURN(VARIANT, (Variant *)this);
FUNCTION_TEST_RETURN(VARIANT, (Variant *)OBJ_NAME(this, Variant::VariantVariantList));
}
/**********************************************************************************************************************************/

View File

@ -271,13 +271,8 @@ xmlDocumentNew(const String *rootName)
xmlInit();
// Create object
XmlDocument *this = NULL;
OBJ_NEW_BEGIN(XmlDocument, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (XmlDocument)
{
.xml = xmlNewDoc(BAD_CAST "1.0"),
@ -307,12 +302,8 @@ xmlDocumentNewBuf(const Buffer *buffer)
xmlInit();
// Create object
XmlDocument *this = NULL;
OBJ_NEW_BEGIN(XmlDocument, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (XmlDocument){{0}}; // Extra braces are required for older gcc versions
if ((this->xml = xmlReadMemory((const char *)bufPtrConst(buffer), (int)bufUsed(buffer), "noname.xml", NULL, 0)) == NULL)

View File

@ -29,14 +29,8 @@ waitNew(TimeMSec waitTime)
ASSERT(waitTime <= 999999000);
// Allocate wait object
Wait *this = NULL;
OBJ_NEW_BEGIN(Wait, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (Wait)
{
.pub =

View File

@ -1436,7 +1436,7 @@ configParse(const Storage *storage, unsigned int argListSize, const char *argLis
// Create the config struct
Config *config;
OBJ_NEW_BEGIN(Config, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Config, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
config = OBJ_NEW_ALLOC();

View File

@ -74,12 +74,8 @@ dbNew(PgClient *client, ProtocolClient *remoteClient, const Storage *const stora
ASSERT(storage != NULL);
ASSERT(applicationName != NULL);
Db *this = NULL;
OBJ_NEW_BEGIN(Db, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (Db)
{
.pub =

View File

@ -100,11 +100,8 @@ infoNew(const String *cipherPass)
FUNCTION_TEST_PARAM(STRING, cipherPass); // Use FUNCTION_TEST so cipher is not logged
FUNCTION_LOG_END();
Info *this = NULL;
OBJ_NEW_BEGIN(Info, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (Info){};
// Cipher used to encrypt/decrypt subsequent dependent files. Value may be NULL.
@ -137,11 +134,8 @@ infoNewLoad(IoRead *const read, InfoLoadNewCallback *const callbackFunction, voi
ASSERT(callbackFunction != NULL);
ASSERT(callbackData != NULL);
Info *this = NULL;
OBJ_NEW_BEGIN(Info, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (Info){};
MEM_CONTEXT_TEMP_BEGIN()

View File

@ -67,9 +67,9 @@ infoArchiveNew(unsigned int pgVersion, uint64_t pgSystemId, const String *cipher
ASSERT(pgVersion > 0 && pgSystemId > 0);
InfoArchive *this = NULL;
InfoArchive *this;
OBJ_NEW_BEGIN(InfoArchive, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoArchive, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoArchiveNewInternal();
@ -92,9 +92,9 @@ infoArchiveNewLoad(IoRead *read)
ASSERT(read != NULL);
InfoArchive *this = NULL;
InfoArchive *this;
OBJ_NEW_BEGIN(InfoArchive, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoArchive, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoArchiveNewInternal();
this->pub.infoPg = infoPgNewLoad(read, infoPgArchive, NULL, NULL);

View File

@ -76,9 +76,9 @@ infoBackupNew(unsigned int pgVersion, uint64_t pgSystemId, unsigned int pgCatalo
ASSERT(pgVersion > 0 && pgSystemId > 0 && pgCatalogVersion > 0);
InfoBackup *this = NULL;
InfoBackup *this;
OBJ_NEW_BEGIN(InfoBackup, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoBackup, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoBackupNewInternal();
@ -239,9 +239,9 @@ infoBackupNewLoad(IoRead *read)
ASSERT(read != NULL);
InfoBackup *this = NULL;
InfoBackup *this;
OBJ_NEW_BEGIN(InfoBackup, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoBackup, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoBackupNewInternal();
this->pub.infoPg = infoPgNewLoad(read, infoPgBackup, infoBackupLoadCallback, this);

View File

@ -69,9 +69,9 @@ infoPgNew(InfoPgType type, const String *cipherPassSub)
FUNCTION_TEST_PARAM(STRING, cipherPassSub);
FUNCTION_LOG_END();
InfoPg *this = NULL;
InfoPg *this;
OBJ_NEW_BEGIN(InfoPg, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoPg, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoPgNewInternal(type);
this->pub.info = infoNew(cipherPassSub);
@ -169,9 +169,9 @@ infoPgNewLoad(IoRead *read, InfoPgType type, InfoLoadNewCallback *callbackFuncti
ASSERT(type == infoPgBackup || type == infoPgArchive);
ASSERT((callbackFunction == NULL && callbackData == NULL) || (callbackFunction != NULL && callbackData != NULL));
InfoPg *this = NULL;
InfoPg *this;
OBJ_NEW_BEGIN(InfoPg, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(InfoPg, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = infoPgNewInternal(type);

View File

@ -1287,9 +1287,9 @@ manifestNewBuild(
ASSERT(storagePg != NULL);
ASSERT(pgVersion != 0);
Manifest *this = NULL;
Manifest *this;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = manifestNewInternal();
this->pub.info = infoNew(NULL);
@ -2338,9 +2338,9 @@ manifestNewLoad(IoRead *read)
ASSERT(read != NULL);
Manifest *this = NULL;
Manifest *this;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = manifestNewInternal();

View File

@ -53,12 +53,8 @@ pgClientNew(const String *host, const unsigned int port, const String *database,
ASSERT(port >= 1 && port <= 65535);
ASSERT(database != NULL);
PgClient *this = NULL;
OBJ_NEW_BEGIN(PgClient, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (PgClient)
{
.pub =

View File

@ -88,12 +88,8 @@ protocolClientNew(const String *name, const String *service, IoRead *read, IoWri
ASSERT(read != NULL);
ASSERT(write != NULL);
ProtocolClient *this = NULL;
OBJ_NEW_BEGIN(ProtocolClient, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (ProtocolClient)
{
.pub =

View File

@ -28,12 +28,8 @@ protocolCommandNew(const StringId command)
ASSERT(command != 0);
ProtocolCommand *this = NULL;
OBJ_NEW_BEGIN(ProtocolCommand, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (ProtocolCommand)
{
.command = command,

View File

@ -45,12 +45,8 @@ protocolParallelNew(TimeMSec timeout, ParallelJobCallback *callbackFunction, voi
ASSERT(callbackFunction != NULL);
ASSERT(callbackData != NULL);
ProtocolParallel *this = NULL;
OBJ_NEW_BEGIN(ProtocolParallel, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (ProtocolParallel)
{
.timeout = timeout,

View File

@ -25,12 +25,8 @@ protocolParallelJobNew(const Variant *key, ProtocolCommand *command)
FUNCTION_LOG_PARAM(PROTOCOL_COMMAND, command);
FUNCTION_LOG_END();
ProtocolParallelJob *this = NULL;
OBJ_NEW_BEGIN(ProtocolParallelJob, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (ProtocolParallelJob)
{
.pub =

View File

@ -40,12 +40,8 @@ protocolServerNew(const String *name, const String *service, IoRead *read, IoWri
ASSERT(read != NULL);
ASSERT(write != NULL);
ProtocolServer *this = NULL;
OBJ_NEW_BEGIN(ProtocolServer, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (ProtocolServer)
{
.read = read,

View File

@ -123,12 +123,8 @@ storageReadAzureNew(
ASSERT(storage != NULL);
ASSERT(name != NULL);
StorageReadAzure *this;
OBJ_NEW_BEGIN(StorageReadAzure, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageReadAzure)
{
.storage = storage,

View File

@ -734,12 +734,8 @@ storageAzureNew(
ASSERT(key != NULL);
ASSERT(blockSize != 0);
StorageAzure *this;
OBJ_NEW_BEGIN(StorageAzure, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageAzure)
{
.interface = storageInterfaceAzure,

View File

@ -274,12 +274,8 @@ storageWriteAzureNew(StorageAzure *const storage, const String *const name, cons
ASSERT(storage != NULL);
ASSERT(name != NULL);
StorageWriteAzure *this;
OBJ_NEW_BEGIN(StorageWriteAzure, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageWriteAzure)
{
.storage = storage,

View File

@ -130,12 +130,8 @@ storageReadGcsNew(
ASSERT(storage != NULL);
ASSERT(name != NULL);
StorageReadGcs *this;
OBJ_NEW_BEGIN(StorageReadGcs, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageReadGcs)
{
.storage = storage,

View File

@ -970,12 +970,8 @@ storageGcsNew(
ASSERT(keyType == storageGcsKeyTypeAuto || key != NULL);
ASSERT(chunkSize != 0);
StorageGcs *this;
OBJ_NEW_BEGIN(StorageGcs, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageGcs)
{
.interface = storageInterfaceGcs,

View File

@ -332,12 +332,8 @@ storageWriteGcsNew(StorageGcs *const storage, const String *const name, const si
ASSERT(storage != NULL);
ASSERT(name != NULL);
StorageWriteGcs *this;
OBJ_NEW_BEGIN(StorageWriteGcs, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageWriteGcs)
{
.storage = storage,

View File

@ -84,7 +84,7 @@ storageItrPathAdd(StorageIterator *const this, const String *const pathSub)
// Add path to top of stack
MEM_CONTEXT_OBJ_BEGIN(this->stack)
{
OBJ_NEW_BEGIN(StorageIteratorInfo, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = 1)
OBJ_NEW_BASE_BEGIN(StorageIteratorInfo, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = 1)
{
StorageIteratorInfo *const listInfo = OBJ_NEW_ALLOC();
@ -132,9 +132,8 @@ storageItrNew(
MEM_CONTEXT_TEMP_BEGIN()
{
OBJ_NEW_BEGIN(StorageIterator, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(StorageIterator, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (StorageIterator)

View File

@ -82,13 +82,8 @@ storageLstNew(const StorageInfoLevel level)
ASSERT(level != storageInfoLevelDefault);
StorageList *this = NULL;
OBJ_NEW_BEGIN(StorageList, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (StorageList)
{
.pub =

View File

@ -220,12 +220,8 @@ storageReadPosixNew(
ASSERT(name != NULL);
StorageReadPosix *this;
OBJ_NEW_BEGIN(StorageReadPosix, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (StorageReadPosix)
{
.storage = storage,

View File

@ -612,12 +612,8 @@ storagePosixNewInternal(
userInit();
// Create the object
StoragePosix *this;
OBJ_NEW_BEGIN(StoragePosix, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StoragePosix)
{
.interface = storageInterfacePosix,

View File

@ -245,12 +245,8 @@ storageWritePosixNew(
ASSERT(modeFile != 0);
ASSERT(modePath != 0);
StorageWritePosix *this;
OBJ_NEW_BEGIN(StorageWritePosix, .childQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (StorageWritePosix)
{
.storage = storage,

View File

@ -39,12 +39,8 @@ storageReadNew(void *const driver, const StorageReadInterface *const interface)
ASSERT(driver != NULL);
ASSERT(interface != NULL);
StorageRead *this;
OBJ_NEW_BEGIN(StorageRead, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageRead)
{
.pub =

View File

@ -303,12 +303,8 @@ storageReadRemoteNew(
ASSERT(client != NULL);
ASSERT(name != NULL);
StorageReadRemote *this;
OBJ_NEW_BEGIN(StorageReadRemote, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), StorageRead::StorageReadRemote);
*this = (StorageReadRemote)
{
.storage = storage,
@ -334,7 +330,7 @@ storageReadRemoteNew(
},
};
this->read = storageReadNew(this, &this->interface);
this->read = storageReadNew(OBJ_NAME(this, StorageRead::StorageReadRemote), &this->interface);
}
OBJ_NEW_END();

View File

@ -486,13 +486,10 @@ storageRemoteNew(
ASSERT(modePath != 0);
ASSERT(client != NULL);
StorageRemote *this;
const String *path;
OBJ_NEW_BEGIN(StorageRemote, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageRemote)
{
.client = client,

View File

@ -209,12 +209,8 @@ storageWriteRemoteNew(
ASSERT(modeFile != 0);
ASSERT(modePath != 0);
StorageWriteRemote *this;
OBJ_NEW_BEGIN(StorageWriteRemote, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX, .callbackQty = 1)
{
this = OBJ_NAME(OBJ_NEW_ALLOC(), StorageWrite::StorageWriteRemote);
*this = (StorageWriteRemote)
{
.storage = storage,
@ -246,7 +242,7 @@ storageWriteRemoteNew(
},
};
this->write = storageWriteNew(this, &this->interface);
this->write = storageWriteNew(OBJ_NAME(this, StorageWrite::StorageWriteRemote), &this->interface);
}
OBJ_NEW_END();

View File

@ -126,12 +126,8 @@ storageReadS3New(
ASSERT(name != NULL);
ASSERT(limit == NULL || varUInt64(limit) > 0);
StorageReadS3 *this;
OBJ_NEW_BEGIN(StorageReadS3, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageReadS3)
{
.storage = storage,

View File

@ -1130,12 +1130,8 @@ storageS3New(
ASSERT(region != NULL);
ASSERT(partSize != 0);
StorageS3 *this;
OBJ_NEW_BEGIN(StorageS3, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageS3)
{
.interface = storageInterfaceS3,

View File

@ -278,12 +278,8 @@ storageWriteS3New(StorageS3 *const storage, const String *const name, const size
ASSERT(storage != NULL);
ASSERT(name != NULL);
StorageWriteS3 *this;
OBJ_NEW_BEGIN(StorageWriteS3, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageWriteS3)
{
.storage = storage,

View File

@ -57,12 +57,8 @@ storageNew(
ASSERT(interface.pathRemove != NULL);
ASSERT(interface.remove != NULL);
Storage *this;
OBJ_NEW_BEGIN(Storage, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (Storage)
{
.pub =

View File

@ -42,12 +42,8 @@ storageWriteNew(void *const driver, const StorageWriteInterface *const interface
ASSERT(driver != NULL);
ASSERT(interface != NULL);
StorageWrite *this;
OBJ_NEW_BEGIN(StorageWrite, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (StorageWrite)
{
.pub =

View File

@ -56,13 +56,8 @@ testBldNew(
ASSERT(module != NULL);
ASSERT(scale != 0);
TestBuild *this = NULL;
OBJ_NEW_BEGIN(TestBuild, .childQty = MEM_CONTEXT_QTY_MAX)
{
// Create object
this = OBJ_NEW_ALLOC();
*this = (TestBuild)
{
.pub =

View File

@ -1961,7 +1961,7 @@ testRun(void)
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.data.backupType = backupTypeFull;
@ -1982,7 +1982,7 @@ testRun(void)
Manifest *manifestResume = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifestResume = manifestNewInternal();
manifestResume->pub.info = infoNew(NULL);
@ -2116,7 +2116,7 @@ testRun(void)
// Create manifest with file
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
HRN_MANIFEST_FILE_ADD(manifest, .name = "pg_data/test");

View File

@ -110,7 +110,7 @@ testManifestMinimal(const String *label, unsigned int pgVersion, const String *p
Manifest *result = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
result = manifestNewInternal();
result->pub.info = infoNew(NULL);
@ -1336,7 +1336,7 @@ testRun(void)
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.data.pgVersion = PG_VERSION_94;
@ -2098,7 +2098,7 @@ testRun(void)
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.info = infoNew(NULL);
@ -2471,7 +2471,7 @@ testRun(void)
#define TEST_PGDATA MANIFEST_TARGET_PGDATA "/"
#define TEST_REPO_PATH STORAGE_REPO_BACKUP "/" TEST_LABEL "/" TEST_PGDATA
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.info = infoNew(NULL);

View File

@ -116,11 +116,8 @@ ioTestFilterSizeResult(THIS_VOID)
static IoFilter *
ioTestFilterSizeNew(const StringId type)
{
IoTestFilterSize *this;
OBJ_NEW_BEGIN(IoTestFilterSize, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoTestFilterSize){0};
}
OBJ_NEW_END();
@ -219,12 +216,8 @@ ioTestFilterMultiplyInputSame(const THIS_VOID)
static IoFilter *
ioTestFilterMultiplyNew(const StringId type, unsigned int multiplier, unsigned int flushTotal, char flushChar)
{
IoTestFilterMultiply *this;
OBJ_NEW_BEGIN(IoTestFilterMultiply, .childQty = MEM_CONTEXT_QTY_MAX)
{
this = OBJ_NEW_ALLOC();
*this = (IoTestFilterMultiply)
{
.bufferFilter = ioBufferNew(),

View File

@ -30,12 +30,8 @@ testObjectFree(TestObject *this)
static TestObject *
testObjectNew(void)
{
TestObject *this = NULL;
OBJ_NEW_BEGIN(TestObject, .childQty = 1)
{
this = OBJ_NEW_ALLOC();
*this = (TestObject)
{
.data = true,

View File

@ -950,7 +950,7 @@ testRun(void)
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.data.backupOptionOnline = true;
@ -1036,7 +1036,7 @@ testRun(void)
Manifest *manifest = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifest = manifestNewInternal();
manifest->pub.info = infoNew(NULL);
@ -1066,7 +1066,7 @@ testRun(void)
Manifest *manifestPrior = NULL;
OBJ_NEW_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
OBJ_NEW_BASE_BEGIN(Manifest, .childQty = MEM_CONTEXT_QTY_MAX)
{
manifestPrior = manifestNewInternal();
manifestPrior->pub.data.backupLabel = strNewZ("20190101-010101F");

Some files were not shown because too many files have changed in this diff Show More