]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pool: rename Free function to Cleanup
authorEric Leblond <eric@regit.org>
Mon, 10 Sep 2012 07:06:41 +0000 (09:06 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 10 Sep 2012 16:07:38 +0000 (18:07 +0200)
This patch renames Free functions to Cleanup as the free is made
by the pool system.

src/app-layer-parser.c
src/defrag.c
src/stream-tcp-reassemble.c
src/stream-tcp.c
src/util-pool.c
src/util-pool.h

index c18c0617cf118ec4d35595631d6e13f7be206b2b..94761798484f821c5e56fefe1b16355fbd9d63df 100644 (file)
@@ -114,7 +114,7 @@ static void *AlpResultElmtPoolAlloc()
     return e;
 }
 
-static void AlpResultElmtPoolFree(void *e)
+static void AlpResultElmtPoolCleanup(void *e)
 {
     AppLayerParserResultElmt *re = (AppLayerParserResultElmt *)e;
 
@@ -1336,7 +1336,7 @@ void RegisterAppLayerParsers(void)
      * \todo Per thread pool */
     al_result_pool = PoolInit(1000, 250,
             sizeof(AppLayerParserResultElmt),
-            AlpResultElmtPoolAlloc, NULL, NULL, AlpResultElmtPoolFree);
+            AlpResultElmtPoolAlloc, NULL, NULL, AlpResultElmtPoolCleanup);
 
     RegisterHTPParsers();
     RegisterSSLParsers();
index e37b4e8709388e2ddeb5210ebff80b8481131cea..0f7bc696ba32fd0931b393096a2d3917fb0286d8 100644 (file)
@@ -379,7 +379,7 @@ DefragTrackerInit(void *data, void *initdata)
  *     the pool.
  */
 static void
-DefragTrackerFree(void *arg)
+DefragTrackerCleanup(void *arg)
 {
     DefragTracker *tracker = arg;
 
@@ -423,7 +423,7 @@ DefragContextNew(void)
     }
     dc->tracker_pool = PoolInit(tracker_pool_size, tracker_pool_size,
         sizeof(DefragTracker),
-        NULL, DefragTrackerInit, dc, DefragTrackerFree);
+        NULL, DefragTrackerInit, dc, DefragTrackerCleanup);
     if (dc->tracker_pool == NULL) {
         SCLogError(SC_ERR_MEM_ALLOC,
             "Defrag: Failed to initialize tracker pool.");
index cba515437121205f9d28ee025bbc232c730ea2e9..c7e83e76a8d508e9c4df216b38cdebb35980dd56 100644 (file)
@@ -195,8 +195,8 @@ int TcpSegmentPoolInit(void *data, void *payload_len)
     return 1;
 }
 
-/** \brief free a tcp segment pool entry */
-void TcpSegmentPoolFree(void *ptr) {
+/** \brief clean up a tcp segment pool entry */
+void TcpSegmentPoolCleanup(void *ptr) {
     if (ptr == NULL)
         return;
 
@@ -286,7 +286,7 @@ int StreamTcpReassembleInit(char quiet)
                                      sizeof (TcpSegment),
                                      TcpSegmentPoolAlloc, TcpSegmentPoolInit,
                                      (void *) &segment_pool_pktsizes[u16],
-                                     TcpSegmentPoolFree);
+                                     TcpSegmentPoolCleanup);
         SCMutexUnlock(&segment_pool_mutex[u16]);
     }
 
index 1fed4ba370982869d9a662afd999200f5951795f..b1e5b6c4894de53b14319befeb8084656440807f 100644 (file)
@@ -270,7 +270,7 @@ int StreamTcpSessionPoolInit(void *data, void* initdata)
 
 /** \brief Pool free function
  *  \param s Void ptr to TcpSession memory */
-void StreamTcpSessionPoolFree(void *s)
+void StreamTcpSessionPoolCleanup(void *s)
 {
     StreamMsg *smsg = NULL;
 
@@ -493,7 +493,7 @@ void StreamTcpInitConfig(char quiet)
                         sizeof(TcpSession),
                         StreamTcpSessionPoolAlloc,
                         StreamTcpSessionPoolInit, NULL,
-                        StreamTcpSessionPoolFree);
+                        StreamTcpSessionPoolCleanup);
     if (ssn_pool == NULL) {
         SCLogError(SC_ERR_POOL_INIT, "ssn_pool is not initialized");
         SCMutexUnlock(&ssn_pool_mutex);
index 6a305ac8ddc5241752e6af22413e3a6b5f53fadd..23d4927a519ab9b988ac89e2331791b977f697ac 100644 (file)
@@ -66,7 +66,7 @@ static int PoolDataPreAllocated(Pool *p, void *data)
 /** \brief Init a Pool
  *
  * PoolInit() creates a ::Pool. The Alloc function must only do
- * allocation stuff. The Free function must not try to free
+ * allocation stuff. The Cleanup function must not try to free
  * the PoolBucket::data. This is done by the ::Pool management
  * system.
  *
@@ -76,10 +76,10 @@ static int PoolDataPreAllocated(Pool *p, void *data)
  * \param Alloc An allocation function or NULL to use a standard SCMalloc
  * \param Init An init function or NULL to use a standard memset to 0
  * \param InitData Init data
- * \Param Free a free function or NULL if no special treatment is needed
+ * \Param Cleanup a free function or NULL if no special treatment is needed
  * \retval the allocated Pool
  */
-Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *(*Alloc)(), int (*Init)(void *, void *), void *InitData,  void (*Free)(void *))
+Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *(*Alloc)(), int (*Init)(void *, void *), void *InitData,  void (*Cleanup)(void *))
 {
     Pool *p = NULL;
 
@@ -100,7 +100,7 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *
     p->Alloc = Alloc;
     p->Init = Init;
     p->InitData = InitData;
-    p->Free = Free;
+    p->Cleanup = Cleanup;
     if (p->Init == NULL) {
         p->Init = PoolMemset;
         p->InitData = p;
@@ -147,8 +147,8 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *
                 goto error;
             }
             if (p->Init(pb->data, p->InitData) != 1) {
-                if (p->Free)
-                    p->Free(pb->data);
+                if (p->Cleanup)
+                    p->Cleanup(pb->data);
                 SCFree(pb->data);
                 SCFree(pb);
                 goto error;
@@ -165,8 +165,8 @@ Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size,  void *
 
             pb->data = (char *)p->data_buffer + u32 * elt_size;
             if (p->Init(pb->data, p->InitData) != 1) {
-                if (p->Free)
-                    p->Free(pb->data);
+                if (p->Cleanup)
+                    p->Cleanup(pb->data);
                 goto error;
             }
 
@@ -198,8 +198,8 @@ void PoolFree(Pool *p) {
     while (p->alloc_list != NULL) {
         PoolBucket *pb = p->alloc_list;
         p->alloc_list = pb->next;
-        if (p->Free)
-            p->Free(pb->data);
+        if (p->Cleanup)
+            p->Cleanup(pb->data);
         if (PoolDataPreAllocated(p, pb->data) == 0) {
             SCFree(pb->data);
         }
@@ -213,8 +213,8 @@ void PoolFree(Pool *p) {
         PoolBucket *pb = p->empty_list;
         p->empty_list = pb->next;
         if (pb->data!= NULL) {
-            if (p->Free)
-                p->Free(pb->data);
+            if (p->Cleanup)
+                p->Cleanup(pb->data);
             if (PoolDataPreAllocated(p, pb->data) == 0) {
                 SCFree(pb->data);
             }
@@ -294,8 +294,8 @@ void PoolReturn(Pool *p, void *data) {
     if (pb == NULL) {
         p->allocated--;
         p->outstanding--;
-        if (p->Free != NULL) {
-            p->Free(data);
+        if (p->Cleanup != NULL) {
+            p->Cleanup(data);
         }
         if (PoolDataPreAllocated(p, data) == 0)
             SCFree(data);
@@ -374,9 +374,9 @@ static int PoolTestInit02 (void) {
         goto end;
     }
 
-    if (p->Free != PoolTestFree) {
+    if (p->Cleanup != PoolTestFree) {
         printf("Free func ptr %p != %p: ",
-            p->Free, PoolTestFree);
+            p->Cleanup, PoolTestFree);
         retval = 0;
         goto end;
     }
index c768258a34ca448166a3134536885a42d28bc407..edc79deffc5170a9bb99a39bc224dcd504cfef6c 100644 (file)
@@ -58,7 +58,7 @@ typedef struct Pool_ {
     void *(*Alloc)();
     int (*Init)(void *, void *);
     void *InitData;
-    void (*Free)(void *);
+    void (*Cleanup)(void *);
 
     uint32_t elt_size;
     uint32_t outstanding;