45 uint32_t elt_size,
void *(*Alloc)(
void),
int (*Init)(
void *,
void *),
46 void *InitData,
void (*Cleanup)(
void *),
void (*Free)(
void *))
65 if (pt->
array == NULL) {
72 for (
int i = 0; i < threads; i++) {
80 e->
pool =
PoolInit(size, prealloc_size, elt_size, Alloc, Init, InitData, Cleanup, Free);
82 if (e->
pool == NULL) {
100 if (pt == NULL || pt->
array == NULL || pt->
size == 0) {
105 size_t newsize = pt->
size + 1;
106 SCLogDebug(
"newsize %"PRIuMAX, (uintmax_t)newsize);
120 memset(&settings, 0x0,
sizeof(settings));
133 e = &pt->
array[newsize - 1];
134 memset(e, 0x00,
sizeof(*e));
141 if (e->
pool == NULL) {
146 return (
int)(newsize - 1);
153 return (
int)pt->
size;
161 if (pt->
array != NULL) {
162 for (
int i = 0; i < (int)pt->
size; i++) {
178 if (pt == NULL ||
id >= pt->
size)
197 if (pt == NULL || *
id >= pt->
size)
235 static void *PoolThreadTestAlloc(
void)
242 int PoolThreadTestInit(
void *data,
void *allocdata)
247 memset(data,0x00,
sizeof(allocdata));
249 pdata->
abc = *(
int *)allocdata;
254 void PoolThreadTestFree(
void *data)
258 static int PoolThreadTestInit01(
void)
261 10, 5, 10, PoolThreadTestAlloc,
262 NULL, NULL, NULL, NULL);
268 static int PoolThreadTestInit02(
void)
274 PoolThreadTestAlloc, PoolThreadTestInit,
275 &i, PoolThreadTestFree, NULL);
281 static int PoolThreadTestGet01(
void)
284 10, 5, 10, PoolThreadTestAlloc,
285 NULL, NULL, NULL, NULL);
298 static int PoolThreadTestGet02(
void)
303 10, 5, 10, PoolThreadTestAlloc,
304 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
319 static int PoolThreadTestReturn01(
void)
324 10, 5, 10, PoolThreadTestAlloc,
325 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
346 static int PoolThreadTestGrow01(
void)
349 10, 5, 10, PoolThreadTestAlloc,
350 NULL, NULL, NULL, NULL);
358 static int PoolThreadTestGrow02(
void)
363 10, 5, 10, PoolThreadTestAlloc,
364 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);
372 static int PoolThreadTestGrow03(
void)
377 10, 5, 10, PoolThreadTestAlloc,
378 PoolThreadTestInit, &i, PoolThreadTestFree, NULL);