axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r479178 - in /webservices/axis2/trunk/c: axiom/src/attachments/ axiom/src/om/ modules/core/transport/http/sender/ samples/client/mtom/
Date Sat, 25 Nov 2006 19:32:54 GMT
Author: samisa
Date: Sat Nov 25 11:32:53 2006
New Revision: 479178

URL: http://svn.apache.org/viewvc?view=rev&rev=479178
Log:
MTOM related memory leak fixes

Modified:
    webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c
    webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c
    webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c
    webservices/axis2/trunk/c/axiom/src/om/om_output.c
    webservices/axis2/trunk/c/axiom/src/om/om_text.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
    webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c

Modified: webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c Sat Nov 25 11:32:53 2006
@@ -290,6 +290,14 @@
                     read_stream_size = 0;
                 }
             }
+            else
+            {
+                if (read_stream)
+                {
+                    AXIS2_FREE(env->allocator, read_stream);
+                    read_stream = NULL;
+                }
+            }
         }
         while (!feof(f));
 

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c Sat Nov 25 11:32:53 2006
@@ -17,6 +17,7 @@
 #include "axiom_mime_body_part.h"
 #include <axiom_data_handler.h>
 #include <axis2_hash.h>
+#include <stdio.h>
 
 typedef struct axiom_mime_body_part_impl
 {
@@ -107,6 +108,21 @@
 
     if (mime_body_part_impl->header_map)
     {
+        axis2_hash_index_t *hash_index = NULL;
+        const void *key = NULL;
+        void *value = NULL;
+        for (hash_index = axis2_hash_first(mime_body_part_impl->header_map, env);
+                    hash_index; hash_index = axis2_hash_next(env, hash_index))
+        {
+            axis2_hash_this(hash_index, &key, NULL, &value);
+            printf("key = %s\n", (char*) key);
+            if (value)
+            {
+                AXIS2_FREE(env->allocator, value);
+            }
+        }
+
+    
         axis2_hash_free(mime_body_part_impl->header_map, env);
         mime_body_part_impl->header_map = NULL;
     }
@@ -163,6 +179,7 @@
     const void *key = NULL;
     void *value = NULL;
     axis2_char_t *header_str = NULL;
+    axis2_char_t *temp_header_str = NULL;
     int header_str_size = 0;
     axis2_byte_t *data_handler_stream = NULL;
     int data_handler_stream_size = 0;
@@ -180,15 +197,31 @@
         axis2_hash_this(hash_index, &key, NULL, &value);
         if (key && value)
         {
-            header_str = AXIS2_STRACAT(header_str, (axis2_char_t*)key, env);
-            header_str = AXIS2_STRACAT(header_str, ": ", env);
-            header_str = AXIS2_STRACAT(header_str, (axis2_char_t*)value, env);
-            header_str = AXIS2_STRACAT(header_str, "\r\n", env);
+            temp_header_str = AXIS2_STRACAT(header_str, (axis2_char_t*)key, env);
+            if (header_str)
+            {
+                AXIS2_FREE(env->allocator, header_str);
+            }
+            header_str = temp_header_str;
+            temp_header_str = AXIS2_STRACAT(header_str, ": ", env);
+            AXIS2_FREE(env->allocator, header_str);
+            header_str = temp_header_str;
+            temp_header_str = AXIS2_STRACAT(header_str, (axis2_char_t*)value, env);
+            AXIS2_FREE(env->allocator, header_str);
+            header_str = temp_header_str;
+            temp_header_str = AXIS2_STRACAT(header_str, "\r\n", env);
+            AXIS2_FREE(env->allocator, header_str);
+            header_str = temp_header_str;
         }
     }
 
     if (mime_body_part_impl->data_handler)
-        header_str = AXIS2_STRACAT(header_str, "\r\n", env);
+    {
+        temp_header_str = AXIS2_STRACAT(header_str, "\r\n", env);
+        AXIS2_FREE(env->allocator, header_str);
+        header_str = temp_header_str;
+
+    }
 
     if (header_str)
         header_str_size = AXIS2_STRLEN(header_str);
@@ -224,9 +257,18 @@
     }
     /*TODO char2byte header_str */
     if (header_str)
+    {
         memcpy(byte_stream, header_str, header_str_size);
+        AXIS2_FREE(env->allocator, header_str);
+        header_str = NULL;
+    }
+
     if (data_handler_stream)
+    {
         memcpy(byte_stream + header_str_size, data_handler_stream, data_handler_stream_size);
+        AXIS2_FREE(env->allocator, data_handler_stream);
+        data_handler_stream = NULL;
+    }
 
     *output_stream = byte_stream;
     *output_stream_size = size;

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c Sat Nov 25 11:32:53 2006
@@ -175,7 +175,9 @@
 {
     axis2_status_t status = AXIS2_FAILURE;
     axis2_char_t *header_value = NULL;
+    axis2_char_t *temp_header_value = NULL;
     axis2_char_t *content_id_string = NULL;
+    axis2_char_t *temp_content_id_string = NULL;
     axiom_mime_body_part_t *root_mime_body_part = NULL;
     axis2_byte_t *output_stream_start = NULL;
     int output_stream_start_size = 0;
@@ -188,6 +190,7 @@
     axis2_byte_t *stream_buffer = NULL;
     int stream_buffer_size = 0;
     int soap_body_buffer_size = 0;
+    axis2_char_t *temp_soap_body_buffer;
 
     AXIS2_ENV_CHECK(env, NULL);
 
@@ -200,23 +203,36 @@
 
     /* content-type */
     header_value = AXIS2_STRDUP("application/xop+xml; charset=", env);
-    header_value = AXIS2_STRACAT(header_value, char_set_encoding, env);
-    header_value = AXIS2_STRACAT(header_value, "; type=\"", env);
-    header_value = AXIS2_STRACAT(header_value, soap_content_type, env);
-    header_value = AXIS2_STRACAT(header_value, "\";", env);
+    temp_header_value = AXIS2_STRACAT(header_value, char_set_encoding, env);
+    AXIS2_FREE(env->allocator, header_value);
+    header_value = temp_header_value;
+    temp_header_value = AXIS2_STRACAT(header_value, "; type=\"", env);
+    AXIS2_FREE(env->allocator, header_value);
+    header_value = temp_header_value;
+    temp_header_value = AXIS2_STRACAT(header_value, soap_content_type, env);
+    AXIS2_FREE(env->allocator, header_value);
+    header_value = temp_header_value;
+    temp_header_value = AXIS2_STRACAT(header_value, "\";", env);
+    AXIS2_FREE(env->allocator, header_value);
+    header_value = temp_header_value;
     AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, "content-type", header_value);
 
     /* content-transfer-encoding */
-    AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, "content-transfer-encoding",
"binary");
+    AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, "content-transfer-encoding",
axis2_strdup("binary", env));
 
     /* content-id */
     content_id_string = (axis2_char_t *)"<";
     content_id_string = AXIS2_STRACAT(content_id_string, content_id, env);
-    content_id_string = AXIS2_STRACAT(content_id_string, ">", env);
+    temp_content_id_string = AXIS2_STRACAT(content_id_string, ">", env);
+    AXIS2_FREE(env->allocator, content_id_string);
+    content_id_string = temp_content_id_string;
     AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, "content-id", content_id_string);
 
     axis2_write_body_part(mime_output, env, &output_stream_body, &output_stream_body_size,
root_mime_body_part, boundary);
 
+    AXIOM_MIME_BODY_PART_FREE(root_mime_body_part, env);
+    root_mime_body_part = NULL;
+
     if (binary_node_list)
     {
         int j = 0;
@@ -277,7 +293,11 @@
 
     if (soap_body_buffer)
     {
-        soap_body_buffer = AXIS2_STRACAT(soap_body_buffer, "\r\n", env);
+        temp_soap_body_buffer = AXIS2_STRACAT(soap_body_buffer, "\r\n", env);
+        
+        AXIS2_FREE(env->allocator, soap_body_buffer);
+        soap_body_buffer = temp_soap_body_buffer;
+        
         soap_body_buffer_size = AXIS2_STRLEN(soap_body_buffer);
     }
 
@@ -386,6 +406,7 @@
     const axis2_char_t *content_type = "application/octet-stream";
     axiom_mime_body_part_t * mime_body_part = axiom_mime_body_part_create(env);
     axis2_char_t *content_id = (axis2_char_t *)"<";
+    axis2_char_t *temp_content_id = NULL;
     if (!mime_body_part)
         return NULL;
     data_handler = AXIOM_TEXT_GET_DATA_HANDLER(text, env);
@@ -399,10 +420,14 @@
             data_handler);
     content_id = AXIS2_STRACAT(content_id,
             AXIOM_TEXT_GET_CONTENT_ID(text, env), env);
-    content_id = AXIS2_STRACAT(content_id, ">", env);
+    temp_content_id = AXIS2_STRACAT(content_id, ">", env);
+    
+    AXIS2_FREE(env->allocator, content_id);
+    content_id = temp_content_id;
+    
     AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, "content-id", content_id);
-    AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, "content-type", content_type);
-    AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, "content-transfer-encoding", "binary");
+    AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, "content-type", axis2_strdup(content_type,
env));
+    AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, "content-transfer-encoding", axis2_strdup("binary",
env));
 
     return mime_body_part;
 }
@@ -502,37 +527,70 @@
         const axis2_char_t *soap_content_type)
 {
     axis2_char_t *content_type_string = NULL;
+    axis2_char_t *temp_content_type_string = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
     content_type_string = AXIS2_STRDUP("multipart/related", env);
-    content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+    temp_content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+    AXIS2_FREE(env->allocator, content_type_string);
+    content_type_string = temp_content_type_string;
     if (boundary)
     {
-        content_type_string = AXIS2_STRACAT(content_type_string, "boundary=", env);
-        content_type_string = AXIS2_STRACAT(content_type_string, boundary, env);
-        content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
-    }
-    content_type_string = AXIS2_STRACAT(content_type_string, "type=\"application/xop+xml\"",
env);
-    content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "boundary=", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, boundary, env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+    }
+    temp_content_type_string = AXIS2_STRACAT(content_type_string, "type=\"application/xop+xml\"",
env);
+    AXIS2_FREE(env->allocator, content_type_string);
+    content_type_string = temp_content_type_string;
+    temp_content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+    AXIS2_FREE(env->allocator, content_type_string);
+    content_type_string = temp_content_type_string;
     if (content_id)
     {
-        content_type_string = AXIS2_STRACAT(content_type_string, "start=\"<", env);
-        content_type_string = AXIS2_STRACAT(content_type_string, content_id , env);
-        content_type_string = AXIS2_STRACAT(content_type_string, ">\"", env);
-        content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "start=\"<", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, content_id , env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, ">\"", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "; ", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
     }
     if (soap_content_type)
     {
-        content_type_string = AXIS2_STRACAT(content_type_string, "start-info=\"", env);
-        content_type_string = AXIS2_STRACAT(content_type_string, soap_content_type, env);
-        content_type_string = AXIS2_STRACAT(content_type_string, "\"; ", env);
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "start-info=\"", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, soap_content_type,
env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "\"; ", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
     }
     if (char_set_encoding)
     {
-        content_type_string = AXIS2_STRACAT(content_type_string, "charset=\"", env);
-        content_type_string = AXIS2_STRACAT(content_type_string, char_set_encoding, env);
-        content_type_string = AXIS2_STRACAT(content_type_string, "\"", env);
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "charset=\"", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, char_set_encoding,
env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
+        temp_content_type_string = AXIS2_STRACAT(content_type_string, "\"", env);
+        AXIS2_FREE(env->allocator, content_type_string);
+        content_type_string = temp_content_type_string;
     }
 
     return content_type_string;

Modified: webservices/axis2/trunk/c/axiom/src/om/om_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_output.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_output.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_output.c Sat Nov 25 11:32:53 2006
@@ -314,6 +314,12 @@
         om_output_impl->binary_node_list = NULL;
     }
 
+    if (om_output_impl->mime_output)
+    {
+        AXIOM_MIME_OUTPUT_FREE(om_output_impl->mime_output, env);
+        om_output_impl->mime_output = NULL;
+    }
+
     if (om_output->ops)
     {
         AXIS2_FREE(env->allocator, om_output->ops);

Modified: webservices/axis2/trunk/c/axiom/src/om/om_text.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_text.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_text.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_text.c Sat Nov 25 11:32:53 2006
@@ -261,6 +261,12 @@
         text_impl->content_id = NULL;
     }
 
+    if (text_impl->om_attribute)
+    {
+        AXIOM_ATTRIBUTE_FREE(text_impl->om_attribute, env);
+        text_impl->om_attribute = NULL;
+    }
+
     if (om_text->ops)
     {
         AXIS2_FREE(env->allocator, om_text->ops);
@@ -279,6 +285,7 @@
     int status = AXIS2_SUCCESS;
     axiom_text_impl_t *om_text_impl = NULL;
     axis2_char_t *attribute_value = NULL;
+    axis2_char_t *temp_attribute_value = NULL;
     axis2_char_t *text = NULL;
     axiom_xml_writer_t *om_output_xml_writer = NULL;
 
@@ -305,9 +312,22 @@
                     om_text_impl->content_id = AXIS2_STRDUP(content_id, env);
             }
             attribute_value = AXIS2_STRDUP("cid:", env);
-            attribute_value = AXIS2_STRACAT(attribute_value, om_text_impl->content_id,
env);
+            temp_attribute_value = AXIS2_STRACAT(attribute_value, om_text_impl->content_id,
env);
+            AXIS2_FREE(env->allocator, attribute_value);
+            attribute_value = temp_attribute_value;
+
             /*send binary as MTOM optimised*/
+            if (om_text_impl->om_attribute)
+            {
+                AXIOM_ATTRIBUTE_FREE(om_text_impl->om_attribute, env);
+                om_text_impl->om_attribute = NULL;
+            }
+
             om_text_impl->om_attribute = axiom_attribute_create(env, "href", attribute_value,
NULL);
+
+            AXIS2_FREE(env->allocator, attribute_value);
+            attribute_value = NULL;
+
             axiom_text_serialize_start_part(om_text, env, om_output);
 
             axiom_output_write_optimized(om_output, env, om_text);

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/soap_over_http_sender.c Sat
Nov 25 11:32:53 2006
@@ -442,6 +442,9 @@
 
     status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request);
 
+    AXIS2_FREE(env->allocator, output_stream);
+    output_stream = NULL;
+
     AXIS2_FREE(env->allocator, buffer);
     buffer = NULL;
 

Modified: webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c?view=diff&rev=479178&r1=479177&r2=479178
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c Sat Nov 25 11:32:53 2006
@@ -37,7 +37,6 @@
     axiom_node_t *ret_node = NULL;
     const axis2_char_t *image_name = "resources/axis2.jpg";
     const axis2_char_t *to_save_name = "test.jpg";
-    axis2_property_t *property = NULL;
     axis2_endpoint_ref_t* reply_to = NULL;
 
 
@@ -63,9 +62,6 @@
 
     /* Create EPR with given address */
     endpoint_ref = axis2_endpoint_ref_create(env, address);
-    property = axis2_property_create(env);
-    AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_APPLICATION);
-    AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_VALUE_TRUE);
 
     /* Setup options */
     options = axis2_options_create(env);
@@ -120,7 +116,10 @@
         axis2_char_t *om_str = NULL;
         om_str = AXIOM_NODE_TO_STRING(ret_node, env);
         if (om_str)
+        {
             printf("\nReceived OM : %s\n", om_str);
+            AXIS2_FREE(env->allocator, om_str);
+        }
         printf("\nmtom client invoke SUCCESSFUL!\n");
     }
     else
@@ -156,6 +155,7 @@
     axiom_node_t* data_om_node = NULL;
     axiom_text_t * data_text = NULL;
     axiom_namespace_t *ns1 = NULL;
+    axis2_char_t *om_str = NULL;
 
     axiom_data_handler_t *data_handler = NULL;
 
@@ -169,6 +169,11 @@
 
     data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");
     data_text = axiom_text_create_with_data_handler(env, image_om_node, data_handler, &data_om_node);
-    printf("%s", AXIOM_NODE_TO_STRING(mtom_om_node, env));
+    om_str = AXIOM_NODE_TO_STRING(mtom_om_node, env);
+    if (om_str)
+    {
+        printf("%s", om_str);
+        AXIS2_FREE(env->allocator, om_str);
+    }
     return mtom_om_node;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message