axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r1713041 - /axis/axis2/c/core/trunk/util/src/allocator.c
Date Fri, 06 Nov 2015 21:46:02 GMT
Author: nadiramra
Date: Fri Nov  6 21:46:01 2015
New Revision: 1713041

URL: http://svn.apache.org/viewvc?rev=1713041&view=rev
Log:
Simplify code

Modified:
    axis/axis2/c/core/trunk/util/src/allocator.c

Modified: axis/axis2/c/core/trunk/util/src/allocator.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/src/allocator.c?rev=1713041&r1=1713040&r2=1713041&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/src/allocator.c (original)
+++ axis/axis2/c/core/trunk/util/src/allocator.c Fri Nov  6 21:46:01 2015
@@ -43,6 +43,7 @@ axutil_allocator_init(
         if (allocator)
         {
             memset(allocator, 0, sizeof(axutil_allocator_t));
+
             allocator->malloc_fn = axutil_allocator_malloc_impl;
             allocator->realloc = axutil_allocator_realloc_impl;
             allocator->free_fn = axutil_allocator_free_impl;
@@ -57,16 +58,15 @@ AXIS2_EXTERN axutil_allocator_t *AXIS2_C
 axutil_allocator_clone(
     axutil_allocator_t * allocator)
 {
-    if(!allocator)
-        return NULL;
+    axutil_allocator_t* clone = NULL;
 
-    else
+    if (allocator)
     {
-        axutil_allocator_t* clone = NULL;
         clone = (axutil_allocator_t *)malloc(sizeof(axutil_allocator_t));
-        memset(clone, 0, sizeof(axutil_allocator_t));
-        if(clone)
+        if (clone)
         {
+            memset(clone, 0, sizeof(axutil_allocator_t));
+
             clone->malloc_fn = allocator->malloc_fn;
             clone->realloc = allocator->realloc;
             clone->free_fn = allocator->free_fn;
@@ -74,20 +74,18 @@ axutil_allocator_clone(
             clone->global_pool = allocator->global_pool;
             clone->local_pool = allocator->local_pool;
             clone->global_pool_ref = 0;
-
-            return clone;
         }
     }
-    return NULL;
+    return clone;
 }
+
 AXIS2_EXTERN void AXIS2_CALL
 axutil_allocator_free(
     axutil_allocator_t * allocator)
 {
-    if(allocator)
-    {
+    if (allocator)
         allocator->free_fn(allocator, allocator);
-    }
+
     return;
 }
 
@@ -120,28 +118,24 @@ AXIS2_EXTERN void AXIS2_CALL
 axutil_allocator_switch_to_global_pool(
     axutil_allocator_t * allocator)
 {
-    if(!allocator)
-        return;
-    allocator->global_pool_ref++;
-    allocator->current_pool = allocator->global_pool;
-    return;
+    if (allocator)
+    {
+        allocator->global_pool_ref++;
+        allocator->current_pool = allocator->global_pool;
+    }
 }
 
 AXIS2_EXTERN void AXIS2_CALL
 axutil_allocator_switch_to_local_pool(
     axutil_allocator_t * allocator)
 {
-    if(!allocator)
-        return;
-    if(allocator->global_pool_ref > 0)
+    if (allocator)
     {
-        allocator->global_pool_ref--;
-    }
+        if (allocator->global_pool_ref > 0)
+            allocator->global_pool_ref--;
 
-    if(allocator->global_pool_ref == 0)
-    {
-        allocator->current_pool = allocator->local_pool;
+        if (allocator->global_pool_ref == 0)
+            allocator->current_pool = allocator->local_pool;
     }
-    return;
 }
 



Mime
View raw message