pool: rename Free function to Cleanup

This patch renames Free functions to Cleanup as the free is made
by the pool system.
pull/66/merge
Eric Leblond 13 years ago committed by Victor Julien
parent f241312a36
commit 619014a280

@ -114,7 +114,7 @@ static void *AlpResultElmtPoolAlloc()
return e;
}
static void AlpResultElmtPoolFree(void *e)
static void AlpResultElmtPoolCleanup(void *e)
{
AppLayerParserResultElmt *re = (AppLayerParserResultElmt *)e;
@ -1336,7 +1336,7 @@ void RegisterAppLayerParsers(void)
* \todo Per thread pool */
al_result_pool = PoolInit(1000, 250,
sizeof(AppLayerParserResultElmt),
AlpResultElmtPoolAlloc, NULL, NULL, AlpResultElmtPoolFree);
AlpResultElmtPoolAlloc, NULL, NULL, AlpResultElmtPoolCleanup);
RegisterHTPParsers();
RegisterSSLParsers();

@ -379,7 +379,7 @@ DefragTrackerInit(void *data, void *initdata)
* the pool.
*/
static void
DefragTrackerFree(void *arg)
DefragTrackerCleanup(void *arg)
{
DefragTracker *tracker = arg;
@ -423,7 +423,7 @@ DefragContextNew(void)
}
dc->tracker_pool = PoolInit(tracker_pool_size, tracker_pool_size,
sizeof(DefragTracker),
NULL, DefragTrackerInit, dc, DefragTrackerFree);
NULL, DefragTrackerInit, dc, DefragTrackerCleanup);
if (dc->tracker_pool == NULL) {
SCLogError(SC_ERR_MEM_ALLOC,
"Defrag: Failed to initialize tracker pool.");

@ -195,8 +195,8 @@ int TcpSegmentPoolInit(void *data, void *payload_len)
return 1;
}
/** \brief free a tcp segment pool entry */
void TcpSegmentPoolFree(void *ptr) {
/** \brief clean up a tcp segment pool entry */
void TcpSegmentPoolCleanup(void *ptr) {
if (ptr == NULL)
return;
@ -286,7 +286,7 @@ int StreamTcpReassembleInit(char quiet)
sizeof (TcpSegment),
TcpSegmentPoolAlloc, TcpSegmentPoolInit,
(void *) &segment_pool_pktsizes[u16],
TcpSegmentPoolFree);
TcpSegmentPoolCleanup);
SCMutexUnlock(&segment_pool_mutex[u16]);
}

@ -270,7 +270,7 @@ int StreamTcpSessionPoolInit(void *data, void* initdata)
/** \brief Pool free function
* \param s Void ptr to TcpSession memory */
void StreamTcpSessionPoolFree(void *s)
void StreamTcpSessionPoolCleanup(void *s)
{
StreamMsg *smsg = NULL;
@ -493,7 +493,7 @@ void StreamTcpInitConfig(char quiet)
sizeof(TcpSession),
StreamTcpSessionPoolAlloc,
StreamTcpSessionPoolInit, NULL,
StreamTcpSessionPoolFree);
StreamTcpSessionPoolCleanup);
if (ssn_pool == NULL) {
SCLogError(SC_ERR_POOL_INIT, "ssn_pool is not initialized");
SCMutexUnlock(&ssn_pool_mutex);

@ -66,7 +66,7 @@ static int PoolDataPreAllocated(Pool *p, void *data)
/** \brief Init a Pool
*
* PoolInit() creates a ::Pool. The Alloc function must only do
* allocation stuff. The Free function must not try to free
* allocation stuff. The Cleanup function must not try to free
* the PoolBucket::data. This is done by the ::Pool management
* system.
*
@ -76,10 +76,10 @@ static int PoolDataPreAllocated(Pool *p, void *data)
* \param Alloc An allocation function or NULL to use a standard SCMalloc
* \param Init An init function or NULL to use a standard memset to 0
* \param InitData Init data
* \Param Free a free function or NULL if no special treatment is needed
* \Param Cleanup a free function or NULL if no special treatment is needed
* \retval the allocated Pool
*/
Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Free)(void *))
Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *))
{
Pool *p = NULL;
@ -100,7 +100,7 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *
p->Alloc = Alloc;
p->Init = Init;
p->InitData = InitData;
p->Free = Free;
p->Cleanup = Cleanup;
if (p->Init == NULL) {
p->Init = PoolMemset;
p->InitData = p;
@ -147,8 +147,8 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *
goto error;
}
if (p->Init(pb->data, p->InitData) != 1) {
if (p->Free)
p->Free(pb->data);
if (p->Cleanup)
p->Cleanup(pb->data);
SCFree(pb->data);
SCFree(pb);
goto error;
@ -165,8 +165,8 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *
pb->data = (char *)p->data_buffer + u32 * elt_size;
if (p->Init(pb->data, p->InitData) != 1) {
if (p->Free)
p->Free(pb->data);
if (p->Cleanup)
p->Cleanup(pb->data);
goto error;
}
@ -198,8 +198,8 @@ void PoolFree(Pool *p) {
while (p->alloc_list != NULL) {
PoolBucket *pb = p->alloc_list;
p->alloc_list = pb->next;
if (p->Free)
p->Free(pb->data);
if (p->Cleanup)
p->Cleanup(pb->data);
if (PoolDataPreAllocated(p, pb->data) == 0) {
SCFree(pb->data);
}
@ -213,8 +213,8 @@ void PoolFree(Pool *p) {
PoolBucket *pb = p->empty_list;
p->empty_list = pb->next;
if (pb->data!= NULL) {
if (p->Free)
p->Free(pb->data);
if (p->Cleanup)
p->Cleanup(pb->data);
if (PoolDataPreAllocated(p, pb->data) == 0) {
SCFree(pb->data);
}
@ -294,8 +294,8 @@ void PoolReturn(Pool *p, void *data) {
if (pb == NULL) {
p->allocated--;
p->outstanding--;
if (p->Free != NULL) {
p->Free(data);
if (p->Cleanup != NULL) {
p->Cleanup(data);
}
if (PoolDataPreAllocated(p, data) == 0)
SCFree(data);
@ -374,9 +374,9 @@ static int PoolTestInit02 (void) {
goto end;
}
if (p->Free != PoolTestFree) {
if (p->Cleanup != PoolTestFree) {
printf("Free func ptr %p != %p: ",
p->Free, PoolTestFree);
p->Cleanup, PoolTestFree);
retval = 0;
goto end;
}

@ -58,7 +58,7 @@ typedef struct Pool_ {
void *(*Alloc)();
int (*Init)(void *, void *);
void *InitData;
void (*Free)(void *);
void (*Cleanup)(void *);
uint32_t elt_size;
uint32_t outstanding;

Loading…
Cancel
Save