apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/test testmem.c
Date Fri, 11 May 2001 00:29:24 GMT
dreid       01/05/10 17:29:24

  Modified:    .        CHANGES STATUS
               memory/unix apr_standard_memory_system.c
                        apr_tracking_memory_system.c
               test     testmem.c
  Log:
  As I'm off to work again tomorrow, here is the final batch of memory changes
  that I have on my HDD.  This includes Sanders patch for getting the tracking
  stuff working again.  Also add some entries to CHANGES and STATUS so we know
  where it's got to.
  
  This means that testmem now works and doesn't segfault.  The formatting should
  be closer to the APR style throughout the code so review should be easier for
  folks.
  
  No more changes to come for a while, so review at leisure.
  
  Enjoy...
  
  Revision  Changes    Path
  1.103     +6 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- CHANGES	2001/05/04 02:39:43	1.102
  +++ CHANGES	2001/05/11 00:29:23	1.103
  @@ -1,5 +1,11 @@
   Changes with APR b1  
   
  +  *) Add memory code kindly donated to APR by  
  +       Elrond  <elrond@samba-tng.org> 
  +       Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
  +       Sander Striker <striker@samba-tng.org>
  +     [David Reid]
  +
     *) Fix a problem with the FreeBSD flavor of apr_sendfile() where we 
        could return APR_EAGAIN+bytes_sent.  [Jeff Trawick]
   
  
  
  
  1.41      +13 -1     apr/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/apr/STATUS,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- STATUS	2001/04/27 20:01:34	1.40
  +++ STATUS	2001/05/11 00:29:23	1.41
  @@ -1,5 +1,5 @@
   APACHE PORTABLE RUNTIME (APR) LIBRARY STATUS:			-*-text-*-
  -Last modified at [$Date: 2001/04/27 20:01:34 $]
  +Last modified at [$Date: 2001/05/11 00:29:23 $]
   
   Release:
   
  @@ -138,6 +138,13 @@
         core_output_filter can then say "setside(conn->pool)" to ensure
         that a saved brigade will last as long as the connection.
   
  +    * APR memory code - code has been added but we still need to
  +      - decide on a better name for the code
  +      - reformat to APR style (think this is now done, but some tabs left)
  +      - test on more systems
  +      - add to the default build as currently it's omitted.  Also need to
  +        add testmem to the test build at that point.
  +      - add more detailed tests to testmem.c
   
   Documentation that needs writing:
   
  @@ -156,3 +163,8 @@
       * Identify and implement those protection bits that have general 
           usefulness, perhaps hidden, generic read-only [immutable],
           effective current user permissions, etc.
  +
  +    * APR memory code
  +      - Look at how we'll handle run-time loading of memory sub systems.
  +      - shared memory module?
  +      - decide on where we're actually going with the code...
  
  
  
  1.3       +2 -3      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_standard_memory_system.c	2001/05/10 10:33:14	1.2
  +++ apr_standard_memory_system.c	2001/05/11 00:29:23	1.3
  @@ -72,7 +72,7 @@
   static 
   void *
   apr_standard_memory_system_malloc(apr_memory_system_t *memory_system,
  -                                  size_t size)
  +                                  apr_size_t size)
   {
       return malloc(size);
   }
  @@ -80,8 +80,7 @@
   static 
   void *
   apr_standard_memory_system_realloc(apr_memory_system_t *memory_system,
  -                                   void *mem,
  -                                   size_t size)
  +                                   void *mem, apr_size_t size)
   {
       return realloc(mem, size);
   }
  
  
  
  1.3       +78 -75    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_tracking_memory_system.c	2001/05/10 10:33:15	1.2
  +++ apr_tracking_memory_system.c	2001/05/11 00:29:23	1.3
  @@ -72,77 +72,76 @@
   /* INTERNALLY USED STRUCTURES */
   typedef struct apr_track_node_t
   {
  -  struct apr_track_node_t *next;
  -  struct apr_track_node_t **ref;
  +    struct apr_track_node_t *next;
  +    struct apr_track_node_t **ref;
   } apr_track_node_t;
   
   typedef struct apr_tracking_memory_system_t
   {
  -  apr_memory_system_t  header;
  -  apr_track_node_t    *nodes;
  +    apr_memory_system_t  header;
  +    apr_track_node_t    *nodes;
   } apr_tracking_memory_system_t;
   
   static 
   void *
   apr_tracking_memory_system_malloc(apr_memory_system_t *memory_system,
  -                                  size_t size)
  +                                  apr_size_t size)
   {
  -  apr_tracking_memory_system_t *tracking_memory_system;
  -  apr_track_node_t *node;
  +    apr_tracking_memory_system_t *tracking_memory_system;
  +    apr_track_node_t *node;
     
  -  assert (memory_system != NULL);
  +    assert (memory_system != NULL);
   
  -  tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  -  node = apr_memory_system_malloc(memory_system->parent_memory_system,
  +    tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  +    node = apr_memory_system_malloc(memory_system->parent_memory_system,
   				  size + sizeof(apr_track_node_t));
  -  if (node == NULL)
  -    return NULL;
  +    if (node == NULL)
  +        return NULL;
   
  -  node->next = tracking_memory_system->nodes;
  -  tracking_memory_system->nodes = node;
  -  node->ref = &tracking_memory_system->nodes;
  -  if (node->next != NULL)
  -    node->next->ref = &node->next;
  +    node->next = tracking_memory_system->nodes;
  +    tracking_memory_system->nodes = node;
  +    node->ref = &tracking_memory_system->nodes;
  +    if (node->next != NULL)
  +        node->next->ref = &node->next;
   
  -  node++;
  +    node++;
   
  -  return (void *)node;
  +    return (void *)node;
   }
   
   static 
   void *
   apr_tracking_memory_system_realloc(apr_memory_system_t *memory_system,
  -                                   void *mem,
  -                                   size_t size)
  +                                   void *mem, apr_size_t size)
   {
  -  apr_tracking_memory_system_t *tracking_memory_system;
  -  apr_track_node_t *node;
  +    apr_tracking_memory_system_t *tracking_memory_system;
  +    apr_track_node_t *node;
   
  -  assert (memory_system != NULL);
  +    assert (memory_system != NULL);
   
  -  tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  -  node = (apr_track_node_t *)mem;
  +    tracking_memory_system = (apr_tracking_memory_system_t *)memory_system;
  +    node = (apr_track_node_t *)mem;
   
  -  if (node != NULL)
  -  {
  -    node--;
  -    *(node->ref) = node->next;
  -  }
  +    if (node != NULL)
  +    {
  +        node--;
  +        *(node->ref) = node->next;
  +    }
   
  -  node = apr_memory_system_realloc(memory_system->parent_memory_system,
  +    node = apr_memory_system_realloc(memory_system->parent_memory_system,
   				   node, size + sizeof(apr_track_node_t));
  -  if (node == NULL)
  -    return NULL;
  +    if (node == NULL)
  +        return NULL;
   
  -  node->next = tracking_memory_system->nodes;
  -  tracking_memory_system->nodes = node;
  -  node->ref = &tracking_memory_system->nodes;
  -  if (node->next != NULL)
  -    node->next->ref = &node->next;
  +    node->next = tracking_memory_system->nodes;
  +    tracking_memory_system->nodes = node;
  +    node->ref = &tracking_memory_system->nodes;
  +    if (node->next != NULL)
  +        node->next->ref = &node->next;
   
  -  node++;
  +    node++;
   
  -  return (void *)node;
  +    return (void *)node;
   }
   
   static 
  @@ -150,17 +149,19 @@
   apr_tracking_memory_system_free(apr_memory_system_t *memory_system,
                                   void *mem)
   {
  -  apr_track_node_t *node;
  +    apr_track_node_t *node;
   
  -  assert (memory_system != NULL);
  -  assert (mem != NULL);
  +    assert (memory_system != NULL);
  +    assert (mem != NULL);
   
  -  node = (apr_track_node_t *)mem;
  -  node--;
  +    node = (apr_track_node_t *)mem;
  +    node--;
   
  -  *(node->ref) = node->next;
  -  
  -  return apr_memory_system_free(memory_system->parent_memory_system, node);
  +    *(node->ref) = node->next;
  +    if (node->next != NULL)
  +        node->next->ref = node->ref;
  +          
  +    return apr_memory_system_free(memory_system->parent_memory_system, node);
   }
   
   static
  @@ -179,6 +180,8 @@
       {
           node = tracking_memory_system->nodes;
           *(node->ref) = node->next;
  +        if (node->next != NULL)
  +            node->next->ref = node->ref;
           if ((rv = apr_memory_system_free(memory_system->parent_memory_system,
                                            node)) != APR_SUCCESS)
               return rv;
  @@ -190,42 +193,42 @@
   void
   apr_tracking_memory_system_destroy(apr_memory_system_t *memory_system)
   {
  -  assert (memory_system != NULL);
  +    assert (memory_system != NULL);
   
  -  apr_tracking_memory_system_reset(memory_system);
  -  apr_memory_system_free(memory_system->parent_memory_system, memory_system);
  +    apr_tracking_memory_system_reset(memory_system);
  +    apr_memory_system_free(memory_system->parent_memory_system, memory_system);
   }
   
   APR_DECLARE(apr_status_t)
   apr_tracking_memory_system_create(apr_memory_system_t **memory_system,
   				  apr_memory_system_t *parent_memory_system)
   {
  -  apr_memory_system_t *new_memory_system;
  -  apr_tracking_memory_system_t *tracking_memory_system;
  +    apr_memory_system_t *new_memory_system;
  +    apr_tracking_memory_system_t *tracking_memory_system;
  +
  +    assert (memory_system != NULL);
  +    assert (parent_memory_system != NULL);
  +
  +    new_memory_system = apr_memory_system_create(
  +        apr_memory_system_malloc(parent_memory_system, 
  +                                 sizeof(apr_tracking_memory_system_t)), 
  +		parent_memory_system);
   
  -  assert (memory_system != NULL);
  -  assert (parent_memory_system != NULL);
  +    *memory_system = NULL;
  +    if (new_memory_system == NULL)
  +        return APR_ENOMEM;
   
  -  new_memory_system = apr_memory_system_create(
  -    apr_memory_system_malloc(parent_memory_system, 
  -                             sizeof(apr_tracking_memory_system_t)), 
  -			     parent_memory_system);
  -
  -  *memory_system = NULL;
  -  if (new_memory_system == NULL)
  -    return APR_ENOMEM;
  -
  -  new_memory_system->malloc_fn = apr_tracking_memory_system_malloc;
  -  new_memory_system->realloc_fn = apr_tracking_memory_system_realloc;
  -  new_memory_system->free_fn = apr_tracking_memory_system_free;
  -  new_memory_system->reset_fn = apr_tracking_memory_system_reset;
  -  new_memory_system->destroy_fn = apr_tracking_memory_system_destroy;
  +    new_memory_system->malloc_fn = apr_tracking_memory_system_malloc;
  +    new_memory_system->realloc_fn = apr_tracking_memory_system_realloc;
  +    new_memory_system->free_fn = apr_tracking_memory_system_free;
  +    new_memory_system->reset_fn = apr_tracking_memory_system_reset;
  +    new_memory_system->destroy_fn = apr_tracking_memory_system_destroy;
   
  -  tracking_memory_system = (apr_tracking_memory_system_t *)new_memory_system;
  -  tracking_memory_system->nodes = NULL;
  +    tracking_memory_system = (apr_tracking_memory_system_t *)new_memory_system;
  +    tracking_memory_system->nodes = NULL;
   
  -  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.3       +1 -1      apr/test/testmem.c
  
  Index: testmem.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testmem.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testmem.c	2001/05/10 10:45:00	1.2
  +++ testmem.c	2001/05/11 00:29:24	1.3
  @@ -149,7 +149,7 @@
       printf("OK\n");
   
       do_test(ams2);
  -    printf("\tAbout to reset the tracking memory..................\n");
  +    printf("\tAbout to reset the tracking memory..................");
       if (apr_memory_system_reset(ams2) != APR_SUCCESS){
           printf("Failed.\n");
           exit(-1);
  
  
  

Mime
View raw message