axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r891127 - in /webservices/axis2/trunk/c/axiom/src/xpath: xpath.c xpath_internals_engine.c xpath_internals_iterators.c
Date Wed, 16 Dec 2009 05:29:07 GMT
Author: shankar
Date: Wed Dec 16 05:29:06 2009
New Revision: 891127

URL: http://svn.apache.org/viewvc?rev=891127&view=rev
Log:
Fixing issue AXIS2C-1366

Modified:
    webservices/axis2/trunk/c/axiom/src/xpath/xpath.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c
    webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath.c?rev=891127&r1=891126&r2=891127&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath.c (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath.c Wed Dec 16 05:29:06 2009
@@ -72,7 +72,9 @@
         return NULL;
     }
     else
+    {
         return expr;
+    }
 }
 
 /* Evaluate compiled XPath expression */
@@ -375,6 +377,25 @@
             context->expr = NULL;
         }
 
+        if (context->root_node)
+        {
+            axiom_node_detach(axiom_node_get_first_child(context->root_node, context->env),
context->env);
+            axiom_node_free_tree(context->root_node, context->env);
+            context->root_node = NULL;
+        }
+
+        if (context->functions)
+        {
+            axutil_hash_free(context->functions, context->env);
+            context->functions = NULL;
+        }
+
+        if(context->namespaces)
+        {
+            axiom_xpath_clear_namespaces(context);
+            context->namespaces = NULL;
+        }
+
         AXIS2_FREE(env->allocator, context);
     }
 }
@@ -394,6 +415,12 @@
             xpath_expr->expr_str = NULL;
         }
 
+        if (xpath_expr->operations)
+        {
+            axutil_array_list_free(xpath_expr->operations, env);
+            xpath_expr->operations = NULL;
+        }
+
         AXIS2_FREE(env->allocator, xpath_expr);
     }
 }

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c?rev=891127&r1=891126&r2=891127&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_engine.c Wed Dec 16 05:29:06
2009
@@ -34,23 +34,25 @@
 
     res->nodes = axutil_array_list_create(context->env, 0);
 
-    context->stack = axutil_stack_create(context->env);
-
     /* Expression is empty */
     if(context->expr->start == AXIOM_XPATH_PARSE_END)
     {
         return res;
     }
 
+    context->stack = axutil_stack_create(context->env);
+
     axiom_xpath_evaluate_operation(context, context->expr->start);
 
     /* Add nodes to the result set from the stack */
     while(axutil_stack_size(context->stack, context->env) > 0)
     {
-        axutil_array_list_add(res->nodes, context->env, axutil_stack_pop(context->stack,
-            context->env));
+        axutil_array_list_add(res->nodes, context->env,
+            axutil_stack_pop(context->stack, context->env));
     }
 
+    axutil_stack_free(context->stack, context->env);
+
     return res;
 }
 
@@ -256,18 +258,20 @@
     {
         res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr, context->env,
i);
 
-        if(res_node->type != AXIOM_XPATH_TYPE_NODE)
+        if(res_node->type == AXIOM_XPATH_TYPE_NODE)
         {
-            continue;
-        }
+            context->node = (axiom_node_t *)res_node->value;
+            context->position = i + 1;
+            context->size = filter_res_n;
 
-        context->node = (axiom_node_t *)res_node->value;
-        context->position = i + 1;
-        context->size = filter_res_n;
+            n_nodes += rel_loc_func(context, rel_loc_op);
+        }
 
-        n_nodes += rel_loc_func(context, rel_loc_op);
+        AXIS2_FREE(context->env->allocator, res_node);
     }
 
+    axutil_array_list_free(arr, context->env);
+
     return n_nodes;
 }
 
@@ -278,6 +282,7 @@
     axiom_xpath_operation_t * op)
 {
     axiom_xpath_result_node_t *node;
+    axiom_xpath_result_node_t *res_node;
     int n_nodes[2];
     int i, j;
     int op12[2];
@@ -330,8 +335,16 @@
         axutil_stack_push(context->stack, context->env, node);
     }
 
-    axutil_array_list_free(arr[0], context->env);
-    axutil_array_list_free(arr[1], context->env);
+    for (i = 1; i >= 0; i--)
+    {
+        for (j = 0; j < n_nodes[i]; j++)
+        {
+            res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env,
j);
+            AXIS2_FREE(context->env->allocator, res_node);
+        }
+
+        axutil_array_list_free(arr[i], context->env);
+    }
 
     return 1;
 }
@@ -343,6 +356,7 @@
     axiom_xpath_operation_t * op)
 {
     axiom_xpath_result_node_t *node;
+    axiom_xpath_result_node_t *res_node;
     int n_nodes[2];
     int i, j;
     int op12[2];
@@ -395,8 +409,16 @@
         axutil_stack_push(context->stack, context->env, node);
     }
 
-    axutil_array_list_free(arr[0], context->env);
-    axutil_array_list_free(arr[1], context->env);
+    for (i = 1; i >= 0; i--)
+    {
+        for (j = 0; j < n_nodes[i]; j++)
+        {
+            res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env,
j);
+            AXIS2_FREE(context->env->allocator, res_node);
+        }
+
+        axutil_array_list_free(arr[i], context->env);
+    }
 
     return 1;
 }
@@ -408,6 +430,7 @@
     axiom_xpath_operation_t * op)
 {
     axiom_xpath_result_node_t *node;
+    axiom_xpath_result_node_t *res_node;
     int n_nodes[2];
     int i, j;
     int op12[2];
@@ -474,8 +497,16 @@
         axutil_stack_push(context->stack, context->env, node);
     }
 
-    axutil_array_list_free(arr[0], context->env);
-    axutil_array_list_free(arr[1], context->env);
+    for (i = 1; i >= 0; i--)
+    {
+        for (j = 0; j < n_nodes[i]; j++)
+        {
+            res_node =(axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env,
j);
+            AXIS2_FREE(context->env->allocator, res_node);
+        }
+
+        axutil_array_list_free(arr[i], context->env);
+    }
 
     return 1;
 }
@@ -592,7 +623,14 @@
     {
         for(i = 0; i < n_nodes; i++)
         {
-            axutil_stack_pop(context->stack, context->env);
+            res = (axiom_xpath_result_node_t *)axutil_stack_pop(context->stack, context->env);
+
+            if (res->type > AXIOM_XPATH_TYPE_NAMESPACE)
+            {
+                AXIS2_FREE(context->env->allocator, res->value);
+            }
+
+            AXIS2_FREE(context->env->allocator, res);
         }
 
         return AXIS2_TRUE;
@@ -605,19 +643,31 @@
         {
             if(*(double *)(res->value) == context->position)
             {
+                AXIS2_FREE(context->env->allocator, res);
                 return AXIS2_TRUE;
             }
             else
             {
-                return AXIS2_FAILURE;
+                AXIS2_FREE(context->env->allocator, res);
+                return AXIS2_FALSE;
             }
         }
         else if(res->type == AXIOM_XPATH_TYPE_BOOLEAN)
         {
-            return *(axis2_bool_t *)(res->value);
+            if(*(axis2_bool_t *)(res->value))
+            {
+                AXIS2_FREE(context->env->allocator, res);
+                return AXIS2_TRUE;
+            }
+            else
+            {
+                AXIS2_FREE(context->env->allocator, res);
+                return AXIS2_FALSE;
+            }
         }
         else
         {
+            AXIS2_FREE(context->env->allocator, res);
             return AXIS2_TRUE;
         }
     }

Modified: webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c?rev=891127&r1=891126&r2=891127&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c (original)
+++ webservices/axis2/trunk/c/axiom/src/xpath/xpath_internals_iterators.c Wed Dec 16 05:29:06
2009
@@ -36,7 +36,6 @@
     axiom_node_t *context_node = NULL;
     /* For streaming */
     axiom_node_t *prev = NULL;
-    /*axiom_xpath_operation_t * next_operation = NULL;*/
 
     AXIOM_XPATH_ITERATOR_INITIALIZE;
     cur = axiom_node_get_first_child(context->node, context->env);
@@ -52,22 +51,6 @@
             n_nodes = axiom_xpath_evaluate_predicate(context, op_next, op_predicate);
             n_nodes_tot += n_nodes;
         }
-        /*
-         if (context->streaming)
-         {
-         if (n_nodes)
-         {
-         next_operation = AXIOM_XPATH_OPR_GET(op_next);
-         }
-
-         if (!n_nodes
-         || next_operation->opr != AXIOM_XPATH_OPERATION_RESULT)
-         {
-         axiom_node_detach(prev, context->env);
-         axiom_node_free_tree(prev, context->env);
-         }
-         }
-         */
     }
 
     /* Change the context node back to what it was */
@@ -123,6 +106,8 @@
 
     context->node = context_node;
 
+    axutil_stack_free(stack, context->env);
+
     return n_nodes;
 }
 
@@ -308,6 +293,8 @@
     /* Change the context node back to what it was */
     context->node = context_node;
 
+    axutil_stack_free(stack, context->env);
+
     return n_nodes;
 }
 
@@ -362,6 +349,8 @@
     /* Change the context node back to what it was */
     context->node = context_node;
 
+    axutil_stack_free(stack, context->env);
+
     return n_nodes;
 }
 
@@ -554,6 +543,8 @@
     /* Change the context node back to what it was */
     context->node = context_node;
 
+    axutil_stack_free(stack, context->env);
+
     return n_nodes;
 }
 



Mime
View raw message