apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)" <madhusudan_mathiha...@hp.com>
Subject RE: cvs commit: apr-util/misc apr_rmm.c
Date Fri, 15 Mar 2002 00:22:39 GMT
Oops.. Sorry. I wanted to rewrite the piece of code before submitting it.
Here's a quickfix, incorporating Aaron's and Doug's comments.

However, at a later part, I was thinking of having the realloc logic
something like :

if (requested_size < current_size) {
  split the current block 
  free the second part
  return
}
else if (requested_size > current_size) {
  if (do_we_have_enough_memory to allocate) {
    allocate memory
    copy from old to new
    free old
    return
  }
  else {
    if (do we have free blocks around this memory so that a bigger chunk can
be formed to satisfy the request) {
      re-adjust the header block
      return
    }
  }
}

any comments. (both patch and the above logic)

-Madhu

Index: apr_rmm.c
===================================================================
RCS file: /home/cvspublic/apr-util/misc/apr_rmm.c,v
retrieving revision 1.10
diff -u -r1.10 apr_rmm.c
--- apr_rmm.c   14 Mar 2002 23:46:29 -0000      1.10
+++ apr_rmm.c   15 Mar 2002 00:17:21 -0000
@@ -383,13 +383,12 @@
     old = apr_rmm_offset_get(rmm, entity);
 
     if ((this = apr_rmm_malloc(rmm, reqsize)) < 0) {
-        return rv;
+        return this;
     }
 
     if (old >= 0) {
         memcpy(apr_rmm_addr_get(rmm, this),
                apr_rmm_addr_get(rmm, old), reqsize);
-        move_block(rmm, old, 1);
         apr_rmm_free(rmm, old);
     }



-----Original Message-----
From: Doug MacEachern [mailto:dougm@covalent.net]
Sent: Thursday, March 14, 2002 4:02 PM
To: Aaron Bannert
Cc: dev@apr.apache.org
Subject: Re: cvs commit: apr-util/misc apr_rmm.c


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?

Mime
View raw message