44 uint32_t elt_size,
void *(*Alloc)(
void),
int (*Init)(
void *,
void *),
45 void *InitData,
void (*Cleanup)(
void *),
void (*Free)(
void *))
64 if (pt->
array == NULL) {
71 for (
int i = 0; i < threads; i++) {
79 e->
pool =
PoolInit(size, prealloc_size, elt_size, Alloc, Init, InitData, Cleanup, Free);
81 if (e->
pool == NULL) {
99 if (pt == NULL || pt->
array == NULL || pt->
size == 0) {
104 size_t newsize = pt->
size + 1;
105 SCLogDebug(
"newsize %"PRIuMAX, (uintmax_t)newsize);
119 memset(&settings, 0x0,
sizeof(settings));
132 e = &pt->
array[newsize - 1];
133 memset(e, 0x00,
sizeof(*e));
140 if (e->
pool == NULL) {
145 return (
int)(newsize - 1);
152 return (
int)pt->
size;
160 if (pt->
array != NULL) {
161 for (
int i = 0; i < (int)pt->
size; i++) {
177 if (pt == NULL ||
id >= pt->
size)
196 if (pt == NULL || *
id >= pt->
size)
234 static void *PoolThreadTestAlloc(
void)
241 int PoolThreadTestInit(
void *data,
void *allocdata)
246 memset(data,0x00,
sizeof(allocdata));
248 pdata->
abc = *(
int *)allocdata;
253 void PoolThreadTestFree(
void *data)
257 static int PoolThreadTestInit01(
void)
260 10, 5, 10, PoolThreadTestAlloc,
261 NULL, NULL, NULL, NULL);
267 static int PoolThreadTestInit02(
void)
273 PoolThreadTestAlloc, PoolThreadTestInit,
274 &i, PoolThreadTestFree, NULL);
280 static int PoolThreadTestGet01(
void)
283 10, 5, 10, PoolThreadTestAlloc,
284 NULL, NULL, NULL, NULL);
297 static int PoolThreadTestGet02(
void)
302 10, 5, 10, PoolThreadTestAlloc,
303 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
318 static int PoolThreadTestReturn01(
void)
323 10, 5, 10, PoolThreadTestAlloc,
324 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
345 static int PoolThreadTestGrow01(
void)
348 10, 5, 10, PoolThreadTestAlloc,
349 NULL, NULL, NULL, NULL);
357 static int PoolThreadTestGrow02(
void)
362 10, 5, 10, PoolThreadTestAlloc,
363 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
371 static int PoolThreadTestGrow03(
void)
376 10, 5, 10, PoolThreadTestAlloc,
377 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);