1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-13 01:00:23 +02:00

Add macros for object free functions.

Most of the *Free() functions are pretty generic so add macros to make creating them as easy as possible.

Create a distinction between *Free() functions that the caller uses to free memory and callbacks that free third-party resources.  There are a number of cases where a driver needs to free resources but does not need a normal *Free() because it is handled by the interface.

Add common/object.h for macros that make object maintenance easier.  This pattern can also be used for many more object functions.
This commit is contained in:
David Steele
2019-05-03 18:52:54 -04:00
parent 7ae96949f1
commit f1eea23121
95 changed files with 684 additions and 910 deletions

View File

@ -9,6 +9,7 @@ Protocol Parallel Executor
#include "common/debug.h"
#include "common/log.h"
#include "common/memContext.h"
#include "common/object.h"
#include "common/type/json.h"
#include "common/type/keyValue.h"
#include "common/type/list.h"
@ -31,6 +32,8 @@ struct ProtocolParallel
ProtocolParallelJobState state; // Overall state of job processing
};
OBJECT_DEFINE_FREE(PROTOCOL_PARALLEL);
/***********************************************************************************************************************************
Create object
***********************************************************************************************************************************/
@ -286,19 +289,3 @@ protocolParallelToLog(const ProtocolParallel *this)
"{state: %s, clientTotal: %u, jobTotal: %u}", protocolParallelJobToConstZ(this->state), lstSize(this->clientList),
lstSize(this->jobList));
}
/***********************************************************************************************************************************
Free object
***********************************************************************************************************************************/
void
protocolParallelFree(ProtocolParallel *this)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(PROTOCOL_PARALLEL, this);
FUNCTION_LOG_END();
if (this != NULL)
memContextFree(this->memContext);
FUNCTION_LOG_RETURN_VOID();
}