You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by do...@apache.org on 2002/03/15 00:18:57 UTC

cvs commit: apr-util/misc apr_rmm.c

dougm       02/03/14 15:18:56

  Modified:    .        CHANGES
               include  apr_rmm.h
               misc     apr_rmm.c
  Log:
  Submitted by:   Madhusudan Mathihalli <ma...@hp.com>
  Reviewed by:	dougm
  add apr_rmm_realloc() function
  
  Revision  Changes    Path
  1.59      +3 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- CHANGES	6 Mar 2002 17:51:22 -0000	1.58
  +++ CHANGES	14 Mar 2002 23:18:56 -0000	1.59
  @@ -1,5 +1,8 @@
   Changes with APR-util b1  
   
  +  *) add apr_rmm_realloc() function
  +     [Madhusudan Mathihalli <ma...@hp.com>]
  +
     *) renames: apr_ansi_time_to_apr_time becomes apr_time_ansi_put
        ap_exploded_time_t becomes apr_time_exp_t
        [Thom May <th...@planetarytramp.net>]
  
  
  
  1.6       +1 -0      apr-util/include/apr_rmm.h
  
  Index: apr_rmm.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_rmm.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apr_rmm.h	13 Mar 2002 20:40:48 -0000	1.5
  +++ apr_rmm.h	14 Mar 2002 23:18:56 -0000	1.6
  @@ -120,6 +120,7 @@
    * @param reqsize How much memory to allocate
    */
   APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize);
  +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, apr_size_t reqsize);
   
   /**
    * Allocate memory from the block of relocatable memory and initialize it to zero.
  
  
  
  1.9       +27 -0     apr-util/misc/apr_rmm.c
  
  Index: apr_rmm.c
  ===================================================================
  RCS file: /home/cvs/apr-util/misc/apr_rmm.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- apr_rmm.c	13 Mar 2002 20:40:49 -0000	1.8
  +++ apr_rmm.c	14 Mar 2002 23:18:56 -0000	1.9
  @@ -368,6 +368,33 @@
       return this;
   }
   
  +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity,
  +                                           apr_size_t reqsize)
  +{
  +    apr_status_t rv;
  +    apr_rmm_off_t this;
  +    apr_rmm_off_t old;
  +
  +    if (!entity) {
  +        return apr_rmm_malloc(rmm, reqsize);
  +    }
  +
  +    reqsize = (1 + (reqsize - 1) / grain) * grain;
  +    old = apr_rmm_offset_get(rmm, entity);
  +
  +    if ((this = apr_rmm_malloc(rmm, reqsize)) < 0) {
  +        return rv;
  +    }
  +
  +    if (old >= 0) {
  +        memcpy(apr_rmm_addr_get(rmm, this),
  +               apr_rmm_addr_get(rmm, old),reqsize);
  +        move_block(rmm, old, 1);
  +    }
  +
  +    return this;
  +}
  +
   APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t this)
   {
       apr_status_t rv;
  
  
  

Re: cvs commit: apr-util/misc apr_rmm.c

Posted by Greg Marr <gr...@alum.wpi.edu>.
On Thu, Mar 14, 2002 at 11:18:57PM -0000, dougm@apache.org wrote:
 > dougm       02/03/14 15:18:56
 >
 >   +    apr_rmm_off_t this;
 >   +
 >   +    if ((this = apr_rmm_malloc(rmm, reqsize)) < 0) {

Don't know if anyone cares, since APR is still in C at this point, 
but "this" is a reserved word in C++, (and so is "new", by the way).

-- 
Greg Marr
gregm@alum.wpi.edu
"We thought you were dead."
"I was, but I'm better now." - Sheridan, "The Summoning"


Re: cvs commit: apr-util/misc apr_rmm.c

Posted by Doug MacEachern <do...@covalent.net>.
just noticed another problem, rv never gets set here:

    apr_status_t rv;
    ...
    if ((this = apr_rmm_malloc(rmm, reqsize)) < 0) {
        return rv;
    }

thinking it should be APR_EINVAL, but the return type of apr_rmm_realloc 
is apr_rmm_off_t.  then again, both apr_rmm_{calloc,malloc} have the same 
return type but return an apr_status_t if APR_ANYLOCK_LOCK fails.
what's up with that?


Re: cvs commit: apr-util/misc apr_rmm.c

Posted by Aaron Bannert <aa...@clove.org>.
apr_rmm_realloc() needs to call apr_rmm_free() with the old block.

-aaron


On Thu, Mar 14, 2002 at 11:18:57PM -0000, dougm@apache.org wrote:
> dougm       02/03/14 15:18:56
> 
>   Modified:    .        CHANGES
>                include  apr_rmm.h
>                misc     apr_rmm.c
>   Log:
>   Submitted by:   Madhusudan Mathihalli <ma...@hp.com>
>   Reviewed by:	dougm
>   add apr_rmm_realloc() function
>   
>   Revision  Changes    Path
>   1.59      +3 -0      apr-util/CHANGES
>   
>   Index: CHANGES
>   ===================================================================
>   RCS file: /home/cvs/apr-util/CHANGES,v
>   retrieving revision 1.58
>   retrieving revision 1.59
>   diff -u -r1.58 -r1.59
>   --- CHANGES	6 Mar 2002 17:51:22 -0000	1.58
>   +++ CHANGES	14 Mar 2002 23:18:56 -0000	1.59
>   @@ -1,5 +1,8 @@
>    Changes with APR-util b1  
>    
>   +  *) add apr_rmm_realloc() function
>   +     [Madhusudan Mathihalli <ma...@hp.com>]
>   +
>      *) renames: apr_ansi_time_to_apr_time becomes apr_time_ansi_put
>         ap_exploded_time_t becomes apr_time_exp_t
>         [Thom May <th...@planetarytramp.net>]
>   
>   
>   
>   1.6       +1 -0      apr-util/include/apr_rmm.h
>   
>   Index: apr_rmm.h
>   ===================================================================
>   RCS file: /home/cvs/apr-util/include/apr_rmm.h,v
>   retrieving revision 1.5
>   retrieving revision 1.6
>   diff -u -r1.5 -r1.6
>   --- apr_rmm.h	13 Mar 2002 20:40:48 -0000	1.5
>   +++ apr_rmm.h	14 Mar 2002 23:18:56 -0000	1.6
>   @@ -120,6 +120,7 @@
>     * @param reqsize How much memory to allocate
>     */
>    APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize);
>   +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, apr_size_t reqsize);
>    
>    /**
>     * Allocate memory from the block of relocatable memory and initialize it to zero.
>   
>   
>   
>   1.9       +27 -0     apr-util/misc/apr_rmm.c
>   
>   Index: apr_rmm.c
>   ===================================================================
>   RCS file: /home/cvs/apr-util/misc/apr_rmm.c,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
>   --- apr_rmm.c	13 Mar 2002 20:40:49 -0000	1.8
>   +++ apr_rmm.c	14 Mar 2002 23:18:56 -0000	1.9
>   @@ -368,6 +368,33 @@
>        return this;
>    }
>    
>   +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity,
>   +                                           apr_size_t reqsize)
>   +{
>   +    apr_status_t rv;
>   +    apr_rmm_off_t this;
>   +    apr_rmm_off_t old;
>   +
>   +    if (!entity) {
>   +        return apr_rmm_malloc(rmm, reqsize);
>   +    }
>   +
>   +    reqsize = (1 + (reqsize - 1) / grain) * grain;
>   +    old = apr_rmm_offset_get(rmm, entity);
>   +
>   +    if ((this = apr_rmm_malloc(rmm, reqsize)) < 0) {
>   +        return rv;
>   +    }
>   +
>   +    if (old >= 0) {
>   +        memcpy(apr_rmm_addr_get(rmm, this),
>   +               apr_rmm_addr_get(rmm, old),reqsize);
>   +        move_block(rmm, old, 1);
>   +    }
>   +
>   +    return this;
>   +}
>   +
>    APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t this)
>    {
>        apr_status_t rv;
>   
>   
>