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 2005/10/25 10:44:16 UTC

svn commit: r328314 - in /webservices/axis2/trunk/c: include/ modules/test/util/ modules/util/src/ modules/util/test/ modules/xml/guththila/src/ modules/xml/om/src/

Author: samisa
Date: Tue Oct 25 01:43:54 2005
New Revision: 328314

URL: http://svn.apache.org/viewcvs?rev=328314&view=rev
Log:
More memory leak fixes

Modified:
    webservices/axis2/trunk/c/include/axis2_hash.h
    webservices/axis2/trunk/c/modules/test/util/test_util.c
    webservices/axis2/trunk/c/modules/util/src/axis2_hash.c
    webservices/axis2/trunk/c/modules/util/test/util_hash_test.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c

Modified: webservices/axis2/trunk/c/include/axis2_hash.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_hash.h?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_hash.h (original)
+++ webservices/axis2/trunk/c/include/axis2_hash.h Tue Oct 25 01:43:54 2005
@@ -140,7 +140,7 @@
  *     axis2_hash_index_t *hi;
  *     void *val;
  *     int sum = 0;
- *     for (hi = axis2_hash_first(p, ht); hi; hi = axis2_hash_next(hi)) {
+ *     for (hi = axis2_hash_first(p, ht); hi; hi = axis2_hash_next(p, hi)) {
  *         axis2_hash_this(hi, NULL, NULL, &val);
  *         sum += *(int *)val;
  *     }
@@ -157,7 +157,7 @@
  * @return a pointer to the updated iteration state.  NULL if there are no more  
  *         entries.
  */
-    axis2_hash_index_t *axis2_hash_next (axis2_hash_index_t * hi);
+    axis2_hash_index_t *axis2_hash_next (axis2_environment_t * environment, axis2_hash_index_t * hi);
 
 /**
  * Get the current entry's details from the iteration state.

Modified: webservices/axis2/trunk/c/modules/test/util/test_util.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/test/util/test_util.c?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/test/util/test_util.c (original)
+++ webservices/axis2/trunk/c/modules/test/util/test_util.c Tue Oct 25 01:43:54 2005
@@ -63,7 +63,7 @@
     axis2_hash_set (ht, key3, AXIS2_HASH_KEY_STRING, a3);
     axis2_hash_set (ht, key4, AXIS2_HASH_KEY_STRING, a4);
 
-    for (i = axis2_hash_first (environment, ht); i; i = axis2_hash_next (i))
+    for (i = axis2_hash_first (environment, ht); i; i = axis2_hash_next (environment, i))
     {
 
         axis2_hash_this (i, NULL, NULL, &v);

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_hash.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_hash.c?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_hash.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_hash.c Tue Oct 25 01:43:54 2005
@@ -115,13 +115,16 @@
  */
 
 axis2_hash_index_t *
-axis2_hash_next (axis2_hash_index_t * hi)
+axis2_hash_next (axis2_environment_t * environment, axis2_hash_index_t * hi)
 {
     hi->this = hi->next;
     while (!hi->this)
     {
         if (hi->index > hi->ht->max)
+		{
+			axis2_free (environment->allocator, hi);
             return NULL;
+		}
 
         hi->this = hi->ht->array[hi->index++];
     }
@@ -142,7 +145,7 @@
     hi->index = 0;
     hi->this = NULL;
     hi->next = NULL;
-    return axis2_hash_next (hi);
+    return axis2_hash_next (environment, hi);
 }
 
 void
@@ -171,7 +174,7 @@
 
     new_max = ht->max * 2 + 1;
     new_array = alloc_array (ht, new_max);
-    for (hi = axis2_hash_first (NULL, ht); hi; hi = axis2_hash_next (hi))
+    for (hi = axis2_hash_first (NULL, ht); hi; hi = axis2_hash_next (NULL, hi))
     {
         unsigned int i = hi->this->hash & new_max;
         hi->this->next = new_array[i];

Modified: webservices/axis2/trunk/c/modules/util/test/util_hash_test.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/test/util_hash_test.c?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/test/util_hash_test.c (original)
+++ webservices/axis2/trunk/c/modules/util/test/util_hash_test.c Tue Oct 25 01:43:54 2005
@@ -30,7 +30,7 @@
 
     axis2_hash_set (ht, key1, AXIS2_HASH_KEY_STRING, actual);
 
-    for (i = axis2_hash_first (environment, ht); i; i = axis2_hash_next (i))
+    for (i = axis2_hash_first (environment, ht); i; i = axis2_hash_next (environment, i))
     {
 
         axis2_hash_this (i, NULL, NULL, &v);

Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c Tue Oct 25 01:43:54 2005
@@ -36,9 +36,6 @@
   parser->attrib = guththila_stack_create (environment);
   parser->namesp = guththila_stack_create (environment);
   parser->dep = guththila_stack_create (environment);
-  /*parser->name = (guththila_token_t *) guththila_malloc (environment->allocator,sizeof (guththila_token_t));
-  parser->prefix = (guththila_token_t *) guththila_malloc (environment->allocator,sizeof (guththila_token_t));
-  parser->value = (guththila_token_t *) guththila_malloc (environment->allocator,sizeof (guththila_token_t));*/
   parser->name = NULL;
   parser->prefix = NULL;
   parser->value = NULL;

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c?rev=328314&r1=328313&r2=328314&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2_om_element.c Tue Oct 25 01:43:54 2005
@@ -253,7 +253,7 @@
     if (!prefix || axis2_strcmp (environment->string, prefix, "") == 0)
     {
         for (hashindex = axis2_hash_first (environment, element->namespaces);
-             hashindex; hashindex = axis2_hash_next (hashindex))
+             hashindex; hashindex = axis2_hash_next (environment, hashindex))
         {
             axis2_hash_this (hashindex, NULL, NULL, &ns);
             if (ns
@@ -444,6 +444,8 @@
 axis2_om_element_impl_free (axis2_environment_t * environment,
                             struct axis2_om_element *element)
 {
+	axis2_status_t status = AXIS2_SUCCESS;
+	
     if (!element)
     {
         environment->error->errorno = AXIS2_ERROR_INVALID_NULL_PARAMETER;
@@ -462,18 +464,35 @@
         }
         if (element->attributes)
         {
+			axis2_free(environment->allocator, element->attributes);
             /* TODO: free attributes */
             /*need to iterate and free individual attributes */
         }
         if (element->namespaces)
         {
+			axis2_hash_index_t *hi;
+			void *val;
+			for (hi = axis2_hash_first (environment, element->namespaces); hi;
+				 hi = axis2_hash_next (environment, hi))
+			{
+				axis2_hash_this (hi, NULL, NULL, &val);
+	/*
+				if (val)
+					status =
+						axis2_om_namespace_free (environment, (axis2_om_namespace_t *)val);
+				else
+				{
+					status = AXIS2_FAILURE;
+				}*/
+			}
+			axis2_free(environment->allocator, element->namespaces);
             /*TODO: free namespaces */
             /*need to eterate and free individual namespaces */
         }
         axis2_free (environment->allocator, element->ops);
         axis2_free (environment->allocator, element);
     }
-    return AXIS2_SUCCESS;
+    return status;
 }
 
 axis2_status_t
@@ -509,7 +528,7 @@
         axis2_hash_index_t *hi;
         void *val;
         for (hi = axis2_hash_first (environment, element->attributes); hi;
-             hi = axis2_hash_next (hi))
+             hi = axis2_hash_next (environment, hi))
         {
             axis2_hash_this (hi, NULL, NULL, &val);
 
@@ -531,7 +550,7 @@
         axis2_hash_index_t *hi;
         void *val;
         for (hi = axis2_hash_first (environment, element->namespaces); hi;
-             hi = axis2_hash_next (hi))
+             hi = axis2_hash_next (environment, hi))
         {
             axis2_hash_this (hi, NULL, NULL, &val);