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 da...@apache.org on 2009/06/18 11:32:36 UTC
svn commit: r785985 - in /webservices/axis2/trunk/c:
src/core/transport/http/sender/http_client.c
src/core/transport/http/sender/http_sender.c
util/include/axutil_allocator.h util/src/allocator.c util/src/thread_pool.c
Author: damitha
Date: Thu Jun 18 09:32:32 2009
New Revision: 785985
URL: http://svn.apache.org/viewvc?rev=785985&view=rev
Log:
Adding an allocator clone
Modified:
webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
webservices/axis2/trunk/c/util/include/axutil_allocator.h
webservices/axis2/trunk/c/util/src/allocator.c
webservices/axis2/trunk/c/util/src/thread_pool.c
Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c?rev=785985&r1=785984&r2=785985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c Thu Jun 18 09:32:32 2009
@@ -331,10 +331,16 @@
/* str_header2 is to hold intermediate value of str_header */
str_header2 = axutil_stracat(env, str_header, header_ext_form);
- AXIS2_FREE(env->allocator, str_header);
- str_header = NULL;
- AXIS2_FREE(env->allocator, header_ext_form);
- header_ext_form = NULL;
+ if(str_header)
+ {
+ AXIS2_FREE(env->allocator, str_header);
+ str_header = NULL;
+ }
+ if(header_ext_form)
+ {
+ AXIS2_FREE(env->allocator, header_ext_form);
+ header_ext_form = NULL;
+ }
/* str_header has all HTTP headers to send. */
str_header = str_header2;
Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c?rev=785985&r1=785984&r2=785985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c Thu Jun 18 09:32:32 2009
@@ -1373,8 +1373,11 @@
axis2_http_simple_request_free (request, env);
request = NULL;
- AXIS2_FREE (env->allocator, output_stream);
- output_stream = NULL;
+ if(output_stream)
+ {
+ AXIS2_FREE (env->allocator, output_stream);
+ output_stream = NULL;
+ }
if (status_code < 0)
{
Modified: webservices/axis2/trunk/c/util/include/axutil_allocator.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axutil_allocator.h?rev=785985&r1=785984&r2=785985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axutil_allocator.h (original)
+++ webservices/axis2/trunk/c/util/include/axutil_allocator.h Thu Jun 18 09:32:32 2009
@@ -122,6 +122,15 @@
axutil_allocator_t * allocator);
/**
+ * Creates a clone of given allocator
+ * @param allocator user defined allocator. Cannot be NULL
+ * @return initialized allocator. NULL on error.
+ */
+ AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
+ axutil_allocator_clone(
+ axutil_allocator_t * allocator);
+
+ /**
* This function should be used to deallocate memory if the default
* allocator was provided by the axutil_allocator_init() call.
* @param allocator allocator struct to be freed
Modified: webservices/axis2/trunk/c/util/src/allocator.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/allocator.c?rev=785985&r1=785984&r2=785985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/allocator.c (original)
+++ webservices/axis2/trunk/c/util/src/allocator.c Thu Jun 18 09:32:32 2009
@@ -56,6 +56,32 @@
return NULL;
}
+AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
+axutil_allocator_clone(
+ axutil_allocator_t * allocator)
+{
+ if (!allocator)
+ return NULL;
+
+ else
+ {
+ axutil_allocator_t* clone = NULL;
+ clone = (axutil_allocator_t *) malloc(sizeof(axutil_allocator_t));
+ memset(clone , 0, sizeof(axutil_allocator_t));
+ if (clone )
+ {
+ clone->malloc_fn = allocator->malloc_fn;
+ clone->realloc = allocator->realloc;
+ clone->free_fn = allocator->free_fn;
+ clone->current_pool = allocator->current_pool;
+ clone->global_pool = allocator->global_pool;
+ clone->local_pool = allocator->local_pool;
+
+ return clone ;
+ }
+ }
+ return NULL;
+}
AXIS2_EXTERN void AXIS2_CALL
axutil_allocator_free(
axutil_allocator_t * allocator)
Modified: webservices/axis2/trunk/c/util/src/thread_pool.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/thread_pool.c?rev=785985&r1=785984&r2=785985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/thread_pool.c (original)
+++ webservices/axis2/trunk/c/util/src/thread_pool.c Thu Jun 18 09:32:32 2009
@@ -116,8 +116,11 @@
axutil_init_thread_env(
const axutil_env_t *system_env)
{
- axutil_error_t *error = axutil_error_create(system_env->allocator);
- return axutil_env_create_with_error_log_thread_pool(system_env->allocator,
+ axutil_allocator_t * allocator = NULL;
+ axutil_error_t *error = NULL;
+ allocator = axutil_allocator_clone(system_env->allocator);
+ error = axutil_error_create(allocator);
+ return axutil_env_create_with_error_log_thread_pool(allocator,
error, system_env->log,
system_env->
thread_pool);