]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pool/thread: remove old grow function
authorVictor Julien <victor@inliniac.net>
Tue, 28 May 2019 13:21:25 +0000 (15:21 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 29 May 2019 13:34:36 +0000 (15:34 +0200)
src/util-pool-thread.c
src/util-pool-thread.h

index 438f95aa7d8e7df66e314db41948e262f037aebd..dc24b9949969e26c7583f4bbfb0a37623d097485 100644 (file)
@@ -140,45 +140,6 @@ int PoolThreadExpand(PoolThread *pt)
     return (int)(newsize - 1);
 }
 
-/**
- *
- */
-int PoolThreadGrow(PoolThread *pt, 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 *))
-{
-    if (pt == NULL || pt->array == NULL) {
-        SCLogError(SC_ERR_POOL_INIT, "pool grow failed");
-        return -1;
-    }
-
-    size_t newsize = pt->size + 1;
-    SCLogDebug("newsize %"PRIuMAX, (uintmax_t)newsize);
-
-    void *ptmp = SCRealloc(pt->array, (newsize * sizeof(PoolThreadElement)));
-    if (ptmp == NULL) {
-        SCFree(pt->array);
-        pt->array = NULL;
-        SCLogError(SC_ERR_POOL_INIT, "pool grow failed");
-        return -1;
-    }
-    pt->array = ptmp;
-    pt->size = newsize;
-
-    PoolThreadElement *e = &pt->array[newsize - 1];
-    memset(e, 0x00, sizeof(*e));
-    SCMutexInit(&e->lock, NULL);
-    SCMutexLock(&e->lock);
-    e->pool = PoolInit(size, prealloc_size, elt_size, Alloc, Init, InitData, Cleanup, Free);
-    SCMutexUnlock(&e->lock);
-    if (e->pool == NULL) {
-        SCLogError(SC_ERR_POOL_INIT, "pool grow failed");
-        return -1;
-    }
-
-    return (int)(newsize - 1);
-}
-
 int PoolThreadSize(PoolThread *pt)
 {
     if (pt == NULL)
@@ -405,8 +366,7 @@ static int PoolThreadTestGrow01(void)
     if (pt == NULL)
         return 0;
 
-    if (PoolThreadGrow(pt,
-                       10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL, NULL) < 0) {
+    if (PoolThreadExpand(pt) < 0) {
         PoolThreadFree(pt);
         return 0;
     }
@@ -424,8 +384,7 @@ static int PoolThreadTestGrow02(void)
     if (pt == NULL)
         return 0;
 
-    if (PoolThreadGrow(pt,
-                       10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree, NULL) < 0) {
+    if (PoolThreadExpand(pt) < 0) {
         PoolThreadFree(pt);
         return 0;
     }
@@ -444,8 +403,7 @@ static int PoolThreadTestGrow03(void)
     if (pt == NULL)
         return 0;
 
-    if (PoolThreadGrow(pt,
-                       10, 5, 10, PoolThreadTestAlloc, PoolThreadTestInit, &i, PoolThreadTestFree, NULL) < 0) {
+    if (PoolThreadExpand(pt) < 0) {
         PoolThreadFree(pt);
         return 0;
     }
index 26d1a5a18ef1c57ff909f20c217808143930ceb6..b1ca22306d51d531a771b6d50e83adea34fd82c8 100644 (file)
@@ -64,12 +64,6 @@ void PoolThreadRegisterTests(void);
  *  \retval pt thread pool or NULL on error */
 PoolThread *PoolThreadInit(int threads, 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 *));
 
-/** \brief grow a thread pool by one
- *  \note calls PoolInit so all args but 'pt' are the same
- *  \param pt thread pool to grow
- *  \retval r id of new entry on succes, -1 on error */
-int PoolThreadGrow(PoolThread *pt, 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 *));
-
 /** \brief grow a thread pool by one
  *  \note copies settings from initial PoolThreadInit() call
  *  \param pt thread pool to grow