You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/03/25 03:22:54 UTC

svn commit: r388689 - in /webservices/axis2/trunk/c/modules: core/deployment/module_builder.c util/hash.c

Author: samisa
Date: Fri Mar 24 18:22:52 2006
New Revision: 388689

URL: http://svn.apache.org/viewcvs?rev=388689&view=rev
Log:
At last I was able to fix the nasty leak in the hash table; what a relief! :-)

Modified:
    webservices/axis2/trunk/c/modules/core/deployment/module_builder.c
    webservices/axis2/trunk/c/modules/util/hash.c

Modified: webservices/axis2/trunk/c/modules/core/deployment/module_builder.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/deployment/module_builder.c?rev=388689&r1=388688&r2=388689&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/deployment/module_builder.c (original)
+++ webservices/axis2/trunk/c/modules/core/deployment/module_builder.c Fri Mar 24 18:22:52 2006
@@ -304,7 +304,8 @@
         status = AXIS2_MODULE_DESC_SET_INFLOW(builder_impl->module_desc, env, flow);
         if(AXIS2_SUCCESS != status)
         {
-            AXIS2_FLOW_FREE(flow, env);
+            if (flow)
+                AXIS2_FLOW_FREE(flow, env);
             return status;
         }
     }

Modified: webservices/axis2/trunk/c/modules/util/hash.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/hash.c?rev=388689&r1=388688&r2=388689&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/hash.c (original)
+++ webservices/axis2/trunk/c/modules/util/hash.c Fri Mar 24 18:22:52 2006
@@ -284,6 +284,7 @@
             && he->klen == klen && memcmp (he->key, key, klen) == 0)
             break;
     }
+    
     if (he || !val)
         return hep;
 
@@ -299,7 +300,6 @@
     he->val = val;
     *hep = he;
     ht->count++;
-    ht->array[hash & ht->max] = *hep;
     return hep;
 }
 
@@ -366,13 +366,11 @@
         if (!val)
         {
             /* delete entry */
-            /*axis2_hash_entry_t *old = *hep;
+            axis2_hash_entry_t *old = *hep;
             *hep = (*hep)->next;
             old->next = ht->free;
-            ht->free = old;*/
+            ht->free = old;
             --ht->count;
-            AXIS2_FREE(ht->environment->allocator, *hep);
-            *hep = NULL;
         }
         else
         {
@@ -528,11 +526,29 @@
     AXIS2_ENV_CHECK(environment, AXIS2_FAILURE);
     if (ht)
     {
-        for(i = 0;i <ht->max; i++)
+        for(i = 0;i <= ht->max; i++)
+        {
+            axis2_hash_entry_t *next = NULL;
+            axis2_hash_entry_t *current = ht->array[i];
+            while(current)
+            {
+                next = current->next;
+                AXIS2_FREE((*environment)->allocator, current);
+                current = NULL;
+                current = next;
+            }
+        }
+        if (ht->free)
         {
-            if(ht->array[i])
+            axis2_hash_entry_t *next = NULL;
+            axis2_hash_entry_t *current = ht->free;
+            int i = 0;
+            while(current)
             {
-                AXIS2_FREE((*environment)->allocator, ht->array[i]);
+                next = current->next;
+                AXIS2_FREE((*environment)->allocator, current);
+                current = NULL;
+                current = next;
             }
         }
         AXIS2_FREE((*environment)->allocator, (ht->array));
@@ -552,9 +568,13 @@
     {
         for(i = 0;i <ht->max; i++)
         {
-            if(ht->array[i])
+            axis2_hash_entry_t *next = NULL;
+            axis2_hash_entry_t *current = ht->array[i];
+            while(current)
             {
-                AXIS2_FREE((*environment)->allocator, ht->array[i]);
+                next = current->next;
+                AXIS2_FREE((*environment)->allocator, current);
+                current = next;
             }
         }
         AXIS2_FREE((*environment)->allocator, (ht->array));