for (i = 0; i < threads; i++) {
PoolThreadElement *e = &pt->array[i];
- if (e == NULL) {
- SCLogDebug("error");
- goto error;
- }
SCMutexInit(&e->lock, NULL);
SCMutexLock(&e->lock);
return pt;
error:
- SCLogDebug("error");
+ if (pt != NULL)
+ PoolThreadFree(pt);
return NULL;
}
pt->size = newsize;
e = &pt->array[newsize - 1];
- if (e == NULL) {
- SCLogError(SC_ERR_POOL_INIT, "pool grow failed");
- return -1;
- }
memset(e, 0x00, sizeof(*e));
SCMutexInit(&e->lock, NULL);
SCMutexLock(&e->lock);
if (pt->array != NULL) {
for (i = 0; i < (int)pt->size; i++) {
PoolThreadElement *e = &pt->array[i];
- if (e == NULL)
- continue;
-
SCMutexLock(&e->lock);
PoolFree(e->pool);
SCMutexUnlock(&e->lock);
return NULL;
PoolThreadElement *e = &pt->array[id];
- if (e) {
- SCMutexLock(&e->lock);
- data = PoolGet(e->pool);
- SCMutexUnlock(&e->lock);
- if (data) {
- PoolThreadReserved *did = data;
- *did = id;
- }
+ SCMutexLock(&e->lock);
+ data = PoolGet(e->pool);
+ SCMutexUnlock(&e->lock);
+ if (data) {
+ PoolThreadReserved *did = data;
+ *did = id;
}
return data;
SCLogDebug("returning to id %u", *id);
PoolThreadElement *e = &pt->array[*id];
- if (e) {
- SCMutexLock(&e->lock);
- PoolReturn(e->pool, data);
- SCMutexUnlock(&e->lock);
- }
+ SCMutexLock(&e->lock);
+ PoolReturn(e->pool, data);
+ SCMutexUnlock(&e->lock);
}
#ifdef UNITTESTS