* \param Free free func
* \retval the allocated Pool
*/
-Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *))
+Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,
+ void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData,
+ void (*Cleanup)(void *), void (*Free)(void *))
{
Pool *p = NULL;
SCLogError(SC_ERR_POOL_INIT, "alloc error");
goto error;
}
- p->pb_buffer = pb;
memset(pb, 0, size * sizeof(PoolBucket));
+ p->pb_buffer = pb;
for (u32 = 0; u32 < size; u32++) {
/* populate pool */
pb->next = p->empty_stack;
p->empty_stack_size++;
pb++;
}
- }
- if (size > 0) {
p->data_buffer = SCCalloc(prealloc_size, elt_size);
/* FIXME better goto */
if (p->data_buffer == NULL) {
SCLogError(SC_ERR_POOL_INIT, "alloc error");
goto error;
}
-
memset(pb, 0, sizeof(PoolBucket));
if (p->Alloc) {
return NULL;
}
-
void PoolFree(Pool *p)
{
if (p == NULL)
}
p->allocated++;
-
p->outstanding++;
+#ifdef DEBUG
if (p->outstanding > p->max_outstanding)
p->max_outstanding = p->outstanding;
+#endif
}
SCReturnPtr(pitem, "void");
void *ptr = pb->data;
pb->data = NULL;
p->outstanding++;
+#ifdef DEBUG
if (p->outstanding > p->max_outstanding)
p->max_outstanding = p->outstanding;
+#endif
SCReturnPtr(ptr,"void");
}