httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jean-frederic clere <jfcl...@gmail.com>
Subject Re: ap_slotmem
Date Wed, 13 May 2009 15:45:01 GMT
Jim Jagielski wrote:
> 
> On May 13, 2009, at 10:17 AM, jean-frederic clere wrote:
> 
>> Jim Jagielski wrote:
>>> OK, I think having 2 more API functions rounds out the impl;
>>> Consider: the current assumption is that the user manages the
>>> indexes into the slotmem. But what if the user doesn't?
>>
>> Then he can't use the stuff :-(
>>
>>> Certainly
>>> it would make sense for the slotmem to know what slots are now
>>> currently available and return a "free" slot to the caller.
>>> So I think a "grab" and a "return" function are required as well.
>>
>> I have malloc() / free() / getused() / getfree()  switchable logic 
>> that I can add quickly. Basically it create a table of used and free 
>> slotmem  additionally to data it.
>>
> 
> *grin*
> 
> Yesterday I added in a 'inuse' table, basically to optimize the 
> ap_slotmem_do()
> function, and already have a 'grab'/'return' impl here ready to svn ci.
> (I'm guessing my grab == malloc and return == free)...

Yes grab = malloc and return == free.

> I like the
> idea of a knowing the amount free and used as well...

My added API is the following:
+++
/**
  * alloc a slot from the slotmem free idems.
  * @param s ap_slotmem_t to use.
  * @param item_id address to return the id of the slot allocates.
  * @param mem address to store the pointer to the slot
  * @return APR_SUCCESS if all went well
  */
apr_status_t (* ap_slotmem_alloc)(ap_slotmem_t *s, int *item_id, void**mem);
/**
  * free a slot (return it to the free list).
  * @param s ap_slotmem_t to use.
  * @param item_id the id of the slot in the slotmem.
  * @param mem pointer to the slot
  * @return APR_SUCCESS if all went well
  */
apr_status_t (* ap_slotmem_free)(ap_slotmem_t *s, int item_id, void*mem);
/**
  * Lock the slotmem.
  * @param s ap_slotmem_t to use.
  * @return APR_SUCCESS if all went well
  */
int (*ap_slotmem_get_used)(ap_slotmem_t *s, int *ids);
/**
  * Return the size of the slotmem table.
  * @param s ap_slotmem_t to use.
  * @return number of slotmem that cant be stored in the slotmem table.
  */
int (*ap_slotmem_get_max_size)(ap_slotmem_t *s);
+++

The code is already tested, should I commit it?

Cheers

Jean-Frederic

Mime
View raw message