axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r581766 - in /webservices/axis2/trunk/c/util: include/axutil_allocator.h src/allocator.c
Date Thu, 04 Oct 2007 03:09:05 GMT
Author: samisa
Date: Wed Oct  3 20:09:04 2007
New Revision: 581766

URL: http://svn.apache.org/viewvc?rev=581766&view=rev
Log:
Fixed logic as well as formatting

Modified:
    webservices/axis2/trunk/c/util/include/axutil_allocator.h
    webservices/axis2/trunk/c/util/src/allocator.c

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=581766&r1=581765&r2=581766&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axutil_allocator.h (original)
+++ webservices/axis2/trunk/c/util/include/axutil_allocator.h Wed Oct  3 20:09:04 2007
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -34,7 +33,6 @@
     /**
      * @defgroup axutil_allocator allocator
      * @ingroup axis2_util
-
      * @{
      */
 
@@ -47,13 +45,13 @@
     {
 
         /**
-          * allocates memory
-          * @param allocator pointer to allocator struct. In the default 
-          * implementation this is not used, however this parameter is useful 
-          * when the allocator implementation is dealing with a memory pool.
-          * @param size size of the memory block to be allocated
-          * @return pointer to the allocated memory block
-          */
+         * Function pointer representing the function that allocates memory.
+         * @param allocator pointer to allocator struct. In the default 
+         * implementation this is not used, however this parameter is useful 
+         * when the allocator implementation is dealing with a memory pool.
+         * @param size size of the memory block to be allocated
+         * @return pointer to the allocated memory block
+         */
         void *(
             AXIS2_CALL
             * malloc_fn)(
@@ -61,14 +59,14 @@
                 size_t size);
 
         /**
-          * re-llocates memory
-          * @param allocator pointer to allocator struct. In the default 
-          * implementation this is not used, however this parameter is useful 
-          * when the allocator implementation is dealing with a memory pool.
-          * @param ptr memory block who's size to be changed
-          * @param size size of the memory block to be allocated
-          * @return pointer to the allocated memory block
-          */
+         * Function pointer representing the function that re-llocates memory.
+         * @param allocator pointer to allocator struct. In the default 
+         * implementation this is not used, however this parameter is useful 
+         * when the allocator implementation is dealing with a memory pool.
+         * @param ptr memory block who's size to be changed
+         * @param size size of the memory block to be allocated
+         * @return pointer to the allocated memory block
+         */
         void *(
             AXIS2_CALL
             * realloc)(
@@ -77,67 +75,85 @@
                 size_t size);
 
         /**
-          * frees memory
-          * @param allocator pointer to allocator struct. In the default 
-          * implementation this is not used, however this parameter is useful 
-          * when the allocator implementation is dealing with a memory pool.
-          * @param ptr pointer to be freed
-          */
+         * Function pointer representing the function that frees memory.
+         * @param allocator pointer to allocator struct. In the default 
+         * implementation this is not used, however this parameter is useful 
+         * when the allocator implementation is dealing with a memory pool.
+         * @param ptr pointer to be freed
+         * @return void
+         */
         void(
             AXIS2_CALL
             * free_fn)(
                 struct axutil_allocator * allocator,
                 void *ptr);
 
-        /** local memory pool */
+        /** 
+         * Local memory pool. Local pool is used to allocate per request 
+         * local values. 
+         */
         void *local_pool;
 
-        /** global memory pool */
+        /** 
+         * Global memory pool. Globale pool is used to allocate values that 
+         * live beyond a request 
+         */
         void *global_pool;
 
-        /** memory pool in use currently */
+        /** 
+         * Memory pool currently in use. The functions
+         * axutil_allocator_switch_to_global_pool and
+         * axutil_allocator_switch_to_local_pool should be used to 
+         * set the current pool to globle pool or to local pool respectively. 
+         */
         void *current_pool;
     }
     axutil_allocator_t;
 
     /**
-      * Initializes (creates) an allocator.
-      * @param allocator user defined allcator. Optional, can be NULL. If NULL, a default
allocator will be returned.
-      * @return initialized allocator. NULL on error.
-      */
+     * Initializes (creates) a memory allocator.
+     * @param allocator user defined allcator. If NULL, a default allocator 
+     * will be returned.
+     * @return initialized allocator. NULL on error.
+     */
     AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
     axutil_allocator_init(
         axutil_allocator_t * allocator);
 
     /**
-      * This function should be used to deallocate memory if the default allocator provided
by
-      * axutil_allocator_init() 
-      * @param 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
+     * @return void
+     */
     AXIS2_EXTERN void AXIS2_CALL
     axutil_allocator_free(
         axutil_allocator_t * allocator);
 
     /**
-      * Swaps the local_pool and global_pool values. 
-      * In case of using pools, local_pool is suppoed to hold the pool out of which
-      * local values are allocated. In case of values that live beyond a request 
-      * globle pool should be used, hence this method has to be called to swithch to 
-      * globle pool for allocation. 
-      * @param allocator allocator whose memory pools are to be switched
+     * Swaps the local_pool and global_pool and makes the global pool the 
+     * current pool.
+     * In case of using pools, local_pool is suppoed to hold the pool out of which
+     * local values are allocated. In case of values that live beyond a request 
+     * globle pool should be used, hence this method has to be called to swithch to 
+     * globle pool for allocation. 
+     * @param allocator allocator whose memory pools are to be switched
+     * @return void
       */
     AXIS2_EXTERN void AXIS2_CALL
     axutil_allocator_switch_to_global_pool(
         axutil_allocator_t * allocator);
 
     /**
-      * Swaps the local_pool and global_pool values. 
-      * In case of using pools, local_pool is suppoed to hold the pool out of which
-      * local values are allocated. In case of values that live beyond a request 
-      * globle pool should be used. This method can be used to inverse the switching 
-      * done by axutil_allocator_switch_to_global_pool, to start using the local pool again.
-      * @param allocator allocator whose memory pools are to be switched
-      */
+     * Swaps the local_pool and global_pool and makes the local pool the 
+     * current pool. 
+     * In case of using pools, local_pool is suppoed to hold the pool out of which
+     * local values are allocated. In case of values that live beyond a request 
+     * globle pool should be used. This method can be used to inverse the switching 
+     * done by axutil_allocator_switch_to_global_pool, to start using the local pool again.
+     * @param allocator allocator whose memory pools are to be switched
+     * @return void
+     */
     AXIS2_EXTERN void AXIS2_CALL
     axutil_allocator_switch_to_local_pool(
         axutil_allocator_t * allocator);

Modified: webservices/axis2/trunk/c/util/src/allocator.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/allocator.c?rev=581766&r1=581765&r2=581766&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/allocator.c (original)
+++ webservices/axis2/trunk/c/util/src/allocator.c Wed Oct  3 20:09:04 2007
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -19,6 +18,7 @@
 #include <axutil_allocator.h>
 #include <axutil_utils.h>
 #include <stdlib.h>
+#include <string.h>
 
 void *AXIS2_CALL axutil_allocator_malloc_impl(
     axutil_allocator_t * allocator,
@@ -43,6 +43,7 @@
     else
     {
         allocator = (axutil_allocator_t *) malloc(sizeof(axutil_allocator_t));
+        memset(allocator, 0, sizeof(axutil_allocator_t)); 
         if (allocator)
         {
             allocator->malloc_fn = axutil_allocator_malloc_impl;
@@ -109,3 +110,4 @@
     allocator->current_pool = allocator->local_pool;
     return;
 }
+



---------------------------------------------------------------------
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