mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Rename pckReadNew()/pckWriteNew() to pckReadNewIo()/pckWriteNewIo().
These names more accurately describe the purpose of the constructors.
This commit is contained in:
parent
0e76ccb5b7
commit
131ac0ab5e
@ -250,7 +250,7 @@ helpRender(const Buffer *const helpData)
|
||||
ioFilterGroupAdd(ioReadFilterGroup(helpRead), bz2DecompressNew());
|
||||
ioReadOpen(helpRead);
|
||||
|
||||
PackRead *pckHelp = pckReadNew(helpRead);
|
||||
PackRead *pckHelp = pckReadNewIo(helpRead);
|
||||
|
||||
// Unpack command data
|
||||
HelpCommandData *commandData = memNew(sizeof(HelpCommandData) * CFG_COMMAND_TOTAL);
|
||||
|
@ -278,7 +278,7 @@ pckReadNewInternal(void)
|
||||
}
|
||||
|
||||
PackRead *
|
||||
pckReadNew(IoRead *read)
|
||||
pckReadNewIo(IoRead *read)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_READ, read);
|
||||
@ -1135,7 +1135,7 @@ pckWriteNewInternal(void)
|
||||
}
|
||||
|
||||
PackWrite *
|
||||
pckWriteNew(IoWrite *write)
|
||||
pckWriteNewIo(IoWrite *write)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(IO_WRITE, write);
|
||||
|
@ -35,7 +35,7 @@ containers. Fields contain data to be stored, e.g. integers, strings, etc.
|
||||
|
||||
Here is a simple example of a pack:
|
||||
|
||||
PackWrite *write = pckWriteNew(buffer);
|
||||
PackWrite *write = pckWriteNewBuf(buffer);
|
||||
pckWriteU64P(write, 77);
|
||||
pckWriteBoolP(write, false, .defaultWrite = true);
|
||||
pckWriteI32P(write, -1, .defaultValue = -1);
|
||||
@ -48,7 +48,7 @@ default. Note that there is a gap in the ID stream, which represents the NULL/de
|
||||
|
||||
This pack can be read with:
|
||||
|
||||
PackRead *read = pckReadNew(buffer);
|
||||
PackRead *read = pckReadNewBuf(buffer);
|
||||
pckReadU64P(read);
|
||||
pckReadBoolP(read);
|
||||
pckReadI32P(read, .defaultValue = -1);
|
||||
@ -60,7 +60,7 @@ applied again when reading by setting .defaultValue if the default value is not
|
||||
|
||||
If we don't care about the NULL/default, another way to read is:
|
||||
|
||||
PackRead *read = pckReadNew(buffer);
|
||||
PackRead *read = pckReadNewBuf(buffer);
|
||||
pckReadU64P(read);
|
||||
pckReadBoolP(read);
|
||||
pckReadStringP(read, .id = 4);
|
||||
@ -132,7 +132,7 @@ typedef enum
|
||||
/***********************************************************************************************************************************
|
||||
Read Constructors
|
||||
***********************************************************************************************************************************/
|
||||
PackRead *pckReadNew(IoRead *read);
|
||||
PackRead *pckReadNewIo(IoRead *read);
|
||||
|
||||
// Note that the buffer is not moved into the PackRead mem context and must be moved explicitly if the PackRead object is moved.
|
||||
PackRead *pckReadNewBuf(const Buffer *buffer);
|
||||
@ -381,7 +381,7 @@ pckReadFree(PackRead *const this)
|
||||
/***********************************************************************************************************************************
|
||||
Write Constructors
|
||||
***********************************************************************************************************************************/
|
||||
PackWrite *pckWriteNew(IoWrite *write);
|
||||
PackWrite *pckWriteNewIo(IoWrite *write);
|
||||
|
||||
// Note that the buffer is not moved into the PackWrite mem context and must be moved explicitly if the PackWrite object is moved.
|
||||
PackWrite *pckWriteNewBuf(Buffer *buffer);
|
||||
|
@ -152,7 +152,7 @@ protocolClientDataPut(ProtocolClient *const this, PackWrite *const data)
|
||||
pckWriteEndP(data);
|
||||
|
||||
// Write the data
|
||||
PackWrite *dataMessage = pckWriteNew(this->write);
|
||||
PackWrite *dataMessage = pckWriteNewIo(this->write);
|
||||
pckWriteU32P(dataMessage, protocolMessageTypeData, .defaultWrite = true);
|
||||
pckWritePackP(dataMessage, data);
|
||||
pckWriteEndP(dataMessage);
|
||||
@ -217,7 +217,7 @@ protocolClientDataGet(ProtocolClient *const this)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
PackRead *response = pckReadNew(this->pub.read);
|
||||
PackRead *response = pckReadNewIo(this->pub.read);
|
||||
ProtocolMessageType type = (ProtocolMessageType)pckReadU32P(response);
|
||||
|
||||
protocolClientError(this, type, response);
|
||||
@ -247,7 +247,7 @@ protocolClientDataEndGet(ProtocolClient *const this)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
PackRead *response = pckReadNew(this->pub.read);
|
||||
PackRead *response = pckReadNewIo(this->pub.read);
|
||||
ProtocolMessageType type = (ProtocolMessageType)pckReadU32P(response);
|
||||
|
||||
protocolClientError(this, type, response);
|
||||
|
@ -58,7 +58,7 @@ protocolCommandPut(ProtocolCommand *const this, IoWrite *const write)
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Write the command and flush to be sure the command gets sent immediately
|
||||
PackWrite *commandPack = pckWriteNew(write);
|
||||
PackWrite *commandPack = pckWriteNewIo(write);
|
||||
pckWriteU32P(commandPack, protocolMessageTypeCommand, .defaultWrite = true);
|
||||
pckWriteStrIdP(commandPack, this->command);
|
||||
|
||||
|
@ -90,7 +90,7 @@ protocolServerError(ProtocolServer *this, int code, const String *message, const
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Write the error and flush to be sure it gets sent immediately
|
||||
PackWrite *error = pckWriteNew(this->write);
|
||||
PackWrite *error = pckWriteNewIo(this->write);
|
||||
pckWriteU32P(error, protocolMessageTypeError);
|
||||
pckWriteI32P(error, code);
|
||||
pckWriteStrP(error, message);
|
||||
@ -116,7 +116,7 @@ protocolServerCommandGet(ProtocolServer *const this)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
PackRead *const command = pckReadNew(this->read);
|
||||
PackRead *const command = pckReadNewIo(this->read);
|
||||
ProtocolMessageType type = (ProtocolMessageType)pckReadU32P(command);
|
||||
|
||||
CHECK(type == protocolMessageTypeCommand);
|
||||
@ -284,7 +284,7 @@ protocolServerDataGet(ProtocolServer *const this)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
PackRead *data = pckReadNew(this->read);
|
||||
PackRead *data = pckReadNewIo(this->read);
|
||||
ProtocolMessageType type = (ProtocolMessageType)pckReadU32P(data);
|
||||
|
||||
CHECK(type == protocolMessageTypeData);
|
||||
@ -318,7 +318,7 @@ protocolServerDataPut(ProtocolServer *const this, PackWrite *const data)
|
||||
pckWriteEndP(data);
|
||||
|
||||
// Write the result
|
||||
PackWrite *resultMessage = pckWriteNew(this->write);
|
||||
PackWrite *resultMessage = pckWriteNewIo(this->write);
|
||||
pckWriteU32P(resultMessage, protocolMessageTypeData, .defaultWrite = true);
|
||||
pckWritePackP(resultMessage, data);
|
||||
pckWriteEndP(resultMessage);
|
||||
@ -343,7 +343,7 @@ protocolServerDataEndPut(ProtocolServer *const this)
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Write the response and flush to be sure it gets sent immediately
|
||||
PackWrite *response = pckWriteNew(this->write);
|
||||
PackWrite *response = pckWriteNewIo(this->write);
|
||||
pckWriteU32P(response, protocolMessageTypeDataEnd, .defaultWrite = true);
|
||||
pckWriteEndP(response);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ testRun(void)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
TEST_ASSIGN(packWrite, pckWriteMove(pckWriteNew(write), memContextPrior()), "move new write");
|
||||
TEST_ASSIGN(packWrite, pckWriteMove(pckWriteNewIo(write), memContextPrior()), "move new write");
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -234,7 +234,7 @@ testRun(void)
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
TEST_ASSIGN(packRead, pckReadMove(pckReadNew(read), memContextPrior()), "move new read");
|
||||
TEST_ASSIGN(packRead, pckReadMove(pckReadNewIo(read), memContextPrior()), "move new read");
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
@ -358,7 +358,7 @@ testRun(void)
|
||||
// Make internal buffer small enough that it will never be used
|
||||
ioBufferSizeSet(0);
|
||||
|
||||
TEST_ASSIGN(packWrite, pckWriteNew(write), "new write");
|
||||
TEST_ASSIGN(packWrite, pckWriteNewIo(write), "new write");
|
||||
TEST_RESULT_VOID(pckWriteStrP(packWrite, STRDEF("test")), "write string longer than internal buffer");
|
||||
TEST_RESULT_VOID(pckWriteEndP(packWrite), "end with internal buffer empty");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user