From 22c8c7829076c148471490bd8b56de2b36d191c6 Mon Sep 17 00:00:00 2001 From: shankar Date: Wed, 24 Mar 2010 07:49:24 +0000 Subject: refactor to improve performance git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@926964 13f79535-47bb-0310-9956-ffa450edef68 --- axiom/src/om/om_comment.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'axiom/src/om/om_comment.c') diff --git a/axiom/src/om/om_comment.c b/axiom/src/om/om_comment.c index ad17f74..2aa9f7f 100644 --- a/axiom/src/om/om_comment.c +++ b/axiom/src/om/om_comment.c @@ -34,14 +34,13 @@ axiom_comment_create( axiom_node_t ** node) { axiom_comment_t *comment = NULL; - AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, value, NULL); AXIS2_PARAM_CHECK(env->error, node, NULL); - *node = NULL; *node = axiom_node_create(env); if(!*node) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create node needed by om comment"); return NULL; } @@ -50,22 +49,26 @@ axiom_comment_create( { AXIS2_FREE(env->allocator, (*node)); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create om comment"); return NULL; } - comment->value = NULL; - if(value) { comment->value = (axis2_char_t *)axutil_strdup(env, value); if(!comment->value) { AXIS2_FREE(env->allocator, comment); - AXIS2_FREE(env->allocator, (*node)); + axiom_node_free_tree(*node, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create comment value"); return NULL; } } + else + { + comment->value = NULL; + } axiom_node_set_data_element((*node), env, comment); axiom_node_set_node_type((*node), env, AXIOM_COMMENT); @@ -83,14 +86,11 @@ axiom_comment_free( axiom_comment_t * comment, const axutil_env_t * env) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - if(comment->value) { AXIS2_FREE(env->allocator, comment->value); } AXIS2_FREE(env->allocator, comment); - return; } AXIS2_EXTERN axis2_char_t *AXIS2_CALL @@ -98,7 +98,6 @@ axiom_comment_get_value( axiom_comment_t * comment, const axutil_env_t * env) { - AXIS2_ENV_CHECK(env, NULL); return comment->value; } @@ -108,7 +107,6 @@ axiom_comment_set_value( const axutil_env_t * env, const axis2_char_t * value) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); if(comment->value) { @@ -131,7 +129,6 @@ axiom_comment_serialize( const axutil_env_t * env, axiom_output_t * om_output) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); if(comment->value) -- cgit v1.1-32-gdbae