RE: apr pool realloc?

2004-07-25 Thread Sander Striker
 From: Branko Cibej [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, July 24, 2004 7:17 PM

 William A. Rowe, Jr. wrote:
 
 At 04:06 AM 7/24/2004, Nick Kew wrote:
 
   
 
 Is there some fundamental reason why there's no apr_prealloc()?
 
 [...] I can't help thinking this should be
  (a) standardised.
  (b) optimised to work with pools.
 
 
 
 I've thought that for some time, with the understanding that 
 you can't 
 be playing in the pool you are reallocing.
 
 See the apr_psprintf() vformatter function for apr's internal 
 implementation, and I'll offer a huge +1 if you care to 
 abstract that 
 behavior :)
   
 
 I thought Sander had apr_prealloc more or less implemented? Sander?

I had, but there was objection against including it.
I can dig it up ofcourse.


Sander



RE: apr pool realloc?

2004-07-25 Thread Nick Kew
On Sun, 25 Jul 2004, Sander Striker wrote:

 I had, but there was objection against including it.
 I can dig it up ofcourse.

Yes please!

If you (or anyone) can dig up a URL for the previous discussion and
reason for the objection, that would be useful, too.  A technical
objection (risk of something breaking or less efficient than
what I posted) would be important to know about; a philosophical
objection can safely be overruled:-)

-- 
Nick Kew


RE: apr pool realloc?

2004-07-25 Thread Sander Striker
 From: Nick Kew [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, July 25, 2004 2:20 PM

 On Sun, 25 Jul 2004, Sander Striker wrote:
 
  I had, but there was objection against including it.
  I can dig it up ofcourse.
 
 Yes please!
 
 If you (or anyone) can dig up a URL for the previous 
 discussion and reason for the objection, that would be 
 useful, too.  A technical objection (risk of something 
 breaking or less efficient than what I posted) would be 
 important to know about; a philosophical objection can safely 
 be overruled:-)

The objection was mostly philosophical.  Lack of demand.

Sander



apr pool realloc?

2004-07-24 Thread Nick Kew

Is there some fundamental reason why there's no apr_prealloc()?

I find myself working around this with constructs like:

typedef struct {
  char* buf ;   /* buffer */
  size_t offset ;   /* bytes used */
  size_t avail ;/* bytes allocated */
} my_realloc_ctx ;

static void my_realloc(apr_pool_t* pool, my_realloc_ctx* ctx, size_t len)
{
  char* newbuf ;
  while ( len  ctx-avail ) {
ctx-avail += BUFSZ ;
  }
  newbuf = realloc(ctx-buf, ctx-avail) ;
  if ( newbuf != ctx-buf ) {
if ( ctx-buf )
apr_pool_cleanup_kill(pool, ctx-buf, (void*)free) ;
apr_pool_cleanup_register(pool, newbuf,
(void*)free, apr_pool_cleanup_null);
ctx-buf = newbuf ;
  }
}

But I can't help thinking this should be
  (a) standardised.
  (b) optimised to work with pools.


-- 
Nick Kew


Re: apr pool realloc?

2004-07-24 Thread William A. Rowe, Jr.
At 04:06 AM 7/24/2004, Nick Kew wrote:

Is there some fundamental reason why there's no apr_prealloc()?

[...] I can't help thinking this should be
  (a) standardised.
  (b) optimised to work with pools.

I've thought that for some time, with the understanding that you can't
be playing in the pool you are reallocing.

See the apr_psprintf() vformatter function for apr's internal implementation,
and I'll offer a huge +1 if you care to abstract that behavior :)

Bill





Re: apr pool realloc?

2004-07-24 Thread Branko Čibej
William A. Rowe, Jr. wrote:
At 04:06 AM 7/24/2004, Nick Kew wrote:
 

Is there some fundamental reason why there's no apr_prealloc()?
[...] I can't help thinking this should be
(a) standardised.
(b) optimised to work with pools.
   

I've thought that for some time, with the understanding that you can't
be playing in the pool you are reallocing.
See the apr_psprintf() vformatter function for apr's internal implementation,
and I'll offer a huge +1 if you care to abstract that behavior :)
 

I thought Sander had apr_prealloc more or less implemented? Sander?
-- Brane