apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/memory/unix apr_memory_system.c apr_standard_memory_system.c apr_tracking_memory_system.c
Date Thu, 10 May 2001 10:33:17 GMT
dreid       01/05/10 03:33:17

  Modified:    include  apr_memory_system.h apr_tracking_memory_system.h
               memory/unix apr_memory_system.c apr_standard_memory_system.c
                        apr_tracking_memory_system.c
  Log:
  Some more updates and small corrections to the memory code.  This starts to
  implement the returning of apr_status_t from more functions.
  
  Submitted by:     Sander Striker <striker@samba-tng.org>
  Reviewed by:	  David Reid <dreid@apache.org>
  
  Revision  Changes    Path
  1.4       +8 -8      apr/include/apr_memory_system.h
  
  Index: apr_memory_system.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_memory_system.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_memory_system.h	2001/05/09 18:11:51	1.3
  +++ apr_memory_system.h	2001/05/10 10:33:09	1.4
  @@ -86,8 +86,8 @@
     void * (*malloc_fn)(apr_memory_system_t *memory_system, apr_size_t size);
     void * (*realloc_fn)(apr_memory_system_t *memory_system, void *memory, 
   		       apr_size_t size);
  -  void (*free_fn)(apr_memory_system_t *memory_system, void *memory);
  -  void (*reset_fn)(apr_memory_system_t *memory_system);
  +  apr_status_t (*free_fn)(apr_memory_system_t *memory_system, void *memory);
  +  apr_status_t (*reset_fn)(apr_memory_system_t *memory_system);
     void (*pre_destroy_fn)(apr_memory_system_t *memory_system);
     void (*destroy_fn)(apr_memory_system_t *memory_system);
     void (*threadsafe_lock_fn)(apr_memory_system_t *memory_system);
  @@ -132,7 +132,7 @@
    * Free a block of memory
    * @param memory_system The memory system to use (should be the same as the
    *        one that returned the block)
  -G * @param mem The block of memory to be freed
  + * @param mem The block of memory to be freed
    * @deffunc void apr_memory_system_free(apr_memory_system_t *memory_system,
    *					void *mem)
    */
  @@ -185,9 +185,9 @@
    *          for the given memory system (i.e. the memory system is non-
    *          tracking).
    * @param memory_system The memory system to be reset
  - * @deffunc void apr_memory_system_reset(apr_memory_system_t *memory_system)
  + * @deffunc apr_status_t apr_memory_system_reset(apr_memory_system_t *memory_system)
    */
  -APR_DECLARE(void)
  +APR_DECLARE(apr_status_t)
   apr_memory_system_reset(apr_memory_system_t *memory_system);
   
   /**
  @@ -196,7 +196,7 @@
    * @caution Be carefull when using this function with a non-tracking memory
    *          system
    * @param memory_system The memory system to be destroyed
  - * @deffunc void apr_memory_system_destroy(apr_memory_system_t *memory_system)
  + * @deffunc apr_status_t apr_memory_system_destroy(apr_memory_system_t *memory_system)
    */
   APR_DECLARE(apr_status_t)
   apr_memory_system_destroy(apr_memory_system_t *memory_system);
  @@ -222,8 +222,8 @@
    * Determine if memory system a is an ancestor of memory system b
    * @param a The memory system to search
    * @param b The memory system to search for
  - * @return TRUE if a is an ancestor of b, FALSE if a is not an ancestor of b
  - * @deffunc apr_bool_t apr_memory_system_is_ancestor(apr_memory_system_t *a,
  + * @return APR_SUCCESS if a is an ancestor of b, 1 if it isn't
  + * @deffunc apr_status_t apr_memory_system_is_ancestor(apr_memory_system_t *a,
    *						     apr_memory_system_t *b)
    */
   APR_DECLARE(apr_status_t) 
  
  
  
  1.3       +2 -2      apr/include/apr_tracking_memory_system.h
  
  Index: apr_tracking_memory_system.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_tracking_memory_system.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_tracking_memory_system.h	2001/05/09 16:44:45	1.2
  +++ apr_tracking_memory_system.h	2001/05/10 10:33:10	1.3
  @@ -67,7 +67,7 @@
    */
   
   /**
  - * Create a tracking malloc/realloc/free memory system
  + * Create a standard malloc/realloc/free memory system
    */
   APR_DECLARE(apr_status_t)
   apr_tracking_memory_system_create(apr_memory_system_t **memory_system,
  @@ -79,4 +79,4 @@
   }
   #endif
   
  -#endif /* !APR_MEMORY_SYSTEM_H */
  +#endif /* !APR_TRACKING_MEMORY_SYSTEM_H */
  
  
  
  1.3       +9 -11     apr/memory/unix/apr_memory_system.c
  
  Index: apr_memory_system.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_memory_system.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_memory_system.c	2001/05/09 18:11:57	1.2
  +++ apr_memory_system.c	2001/05/10 10:33:13	1.3
  @@ -125,7 +125,7 @@
           return APR_EINVAL; /* Hmm, is this an error??? */
   
       if (memory_system->free_fn != NULL)
  -        memory_system->free_fn(memory_system, mem);  
  +        return memory_system->free_fn(memory_system, mem);  
   
   #ifdef APR_MEMORY_SYSTEM_DEBUG
       else /* assume this is a tracking memory system */
  @@ -301,7 +301,7 @@
       }
   }
   
  -APR_DECLARE(void)
  +APR_DECLARE(apr_status_t)
   apr_memory_system_reset(apr_memory_system_t *memory_system)
   {
       assert(memory_system != NULL);
  @@ -330,7 +330,7 @@
       memory_system->accounting_memory_system = memory_system;
   
       /* Let the memory system handle the actual reset */
  -    memory_system->reset_fn(memory_system);
  +    return memory_system->reset_fn(memory_system);
   }
   
   APR_DECLARE(apr_status_t)
  @@ -515,24 +515,22 @@
       assert(memory_system != NULL);
       assert(memory_system->accounting_memory_system != NULL);
   
  -    /*
  -     * If someone passes us a NULL cleanup_fn, assert, because the cleanup
  -     * code can't handle it _and_ it makes no sense.
  -     */
  +    if (cleanup_fn == NULL)
  +        return APR_EINVAL;
  +
       cleanup = (struct apr_memory_system_cleanup *)
   	    apr_memory_system_malloc(memory_system->accounting_memory_system,
   				     sizeof(struct apr_memory_system_cleanup));
   
  -    /* See if we actually got the memory */
       if (cleanup == NULL)
  -        return APR_ENOMEM; /* strikerXXX: Should this become APR_FALSE? */
  +        return APR_ENOMEM;
   
       cleanup->data = data;
       cleanup->cleanup_fn = cleanup_fn;
       cleanup->next = memory_system->cleanups;
       memory_system->cleanups = cleanup;
   
  -    return APR_SUCCESS; /* strikerXXX: Should this become APR_TRUE? */
  +    return APR_SUCCESS;
   }
   
   APR_DECLARE(apr_status_t)
  @@ -559,7 +557,7 @@
               if (memory_system->free_fn != NULL)
                   apr_memory_system_free(memory_system, cleanup);
   
  -            return APR_SUCCESS; /* strikerXXX: Should this become APR_TRUE? */
  +            return APR_SUCCESS;
           }
   
           cleanup_ref = &cleanup->next;
  
  
  
  1.2       +18 -21    apr/memory/unix/apr_standard_memory_system.c
  
  Index: apr_standard_memory_system.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_standard_memory_system.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_standard_memory_system.c	2001/05/09 15:36:13	1.1
  +++ apr_standard_memory_system.c	2001/05/10 10:33:14	1.2
  @@ -65,10 +65,6 @@
   #include <stdlib.h>
   #include <assert.h>
   
  -#include <memory.h> /* strikerXXX: had to add this for windows to stop 
  -                     * complaining, please autoconf the include stuff
  -		     */
  -
   /*
    * standard memory system
    */
  @@ -78,7 +74,7 @@
   apr_standard_memory_system_malloc(apr_memory_system_t *memory_system,
                                     size_t size)
   {
  -  return malloc(size);
  +    return malloc(size);
   }
   
   static 
  @@ -87,37 +83,38 @@
                                      void *mem,
                                      size_t size)
   {
  -  return realloc(mem, size);
  +    return realloc(mem, size);
   }
   
   static 
  -void
  +apr_status_t
   apr_standard_memory_system_free(apr_memory_system_t *memory_system,
                                   void *mem)
   {
  -  free(mem);
  +    free(mem);
  +    return APR_SUCCESS;
   }
   
   APR_DECLARE(apr_status_t)
   apr_standard_memory_system_create(apr_memory_system_t **memory_system)
   {
  -  apr_memory_system_t *new_memory_system;
  +    apr_memory_system_t *new_memory_system;
   
  -  assert(memory_system != NULL);
  +    assert(memory_system != NULL);
   
  -  *memory_system = NULL;
  -  new_memory_system = apr_memory_system_create(
  -    malloc(sizeof(apr_memory_system_t)), NULL);
  +    *memory_system = NULL;
  +    new_memory_system = apr_memory_system_create(
  +        malloc(sizeof(apr_memory_system_t)), NULL);
   
  -  if (new_memory_system == NULL)
  -    return APR_ENOMEM;
  +    if (new_memory_system == NULL)
  +        return APR_ENOMEM;
   
  -  new_memory_system->malloc_fn = apr_standard_memory_system_malloc;
  -  new_memory_system->realloc_fn = apr_standard_memory_system_realloc;
  -  new_memory_system->free_fn = apr_standard_memory_system_free;
  +    new_memory_system->malloc_fn = apr_standard_memory_system_malloc;
  +    new_memory_system->realloc_fn = apr_standard_memory_system_realloc;
  +    new_memory_system->free_fn = apr_standard_memory_system_free;
   
  -  apr_memory_system_assert(new_memory_system);
  +    apr_memory_system_assert(new_memory_system);
   
  -  *memory_system = new_memory_system;
  -  return APR_SUCCESS;
  +    *memory_system = new_memory_system;
  +    return APR_SUCCESS;
   }
  
  
  
  1.2       +20 -16    apr/memory/unix/apr_tracking_memory_system.c
  
  Index: apr_tracking_memory_system.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_tracking_memory_system.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_tracking_memory_system.c	2001/05/09 15:36:13	1.1
  +++ apr_tracking_memory_system.c	2001/05/10 10:33:15	1.2
  @@ -146,7 +146,7 @@
   }
   
   static 
  -void
  +apr_status_t
   apr_tracking_memory_system_free(apr_memory_system_t *memory_system,
                                   void *mem)
   {
  @@ -160,26 +160,30 @@
   
     *(node->ref) = node->next;
     
  -  apr_memory_system_free(memory_system->parent_memory_system, node);
  +  return apr_memory_system_free(memory_system->parent_memory_system, node);
   }
   
   static
  -void
  +apr_status_t
   apr_tracking_memory_system_reset(apr_memory_system_t *memory_system)
   {
  -  apr_tracking_memory_system_t *tracking_memory_system;
  -  apr_track_node_t *node;
  -
  -  assert (memory_system != NULL);
  -
  -  tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  -
  -  while (tracking_memory_system->nodes != NULL)
  -  {
  -    node = tracking_memory_system->nodes;
  -    *(node->ref) = node->next;
  -    apr_memory_system_free(memory_system->parent_memory_system, node);
  -  }
  +    apr_tracking_memory_system_t *tracking_memory_system;
  +    apr_track_node_t *node;
  +    apr_status_t rv;
  +    
  +    assert (memory_system != NULL);
  +
  +    tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  +
  +    while (tracking_memory_system->nodes != NULL)
  +    {
  +        node = tracking_memory_system->nodes;
  +        *(node->ref) = node->next;
  +        if ((rv = apr_memory_system_free(memory_system->parent_memory_system,
  +                                         node)) != APR_SUCCESS)
  +            return rv;
  +    }
  +    return APR_SUCCESS;
   }
   
   static
  
  
  

Mime
View raw message