Re: TLV to memPools

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Mon, 08 Oct 2001 17:55:04 +0200

To answer your question: To make sure the the caller knows what he/she
is freeing. The size field sent to memFreeBuf is the same field as
returned via gross_size in memAllocBuf.

A related questions is:

Why do we have 2 different and incompatible buffer implementations?

MemBuf
String

The two provide basically the same functionality with only some minor
twists. The main difference is the buffer sizes.

  String uses the memBufAlloc/Free API to manage 36 bytes, 128 bytes,
512 bytes and xmallocs anything larger.

  MemBuf manages 2K, 4K, 8K, 16K, 32K, 64K buffers using the MEM_xK_BUF
mempools, and xmallocs anything larger.

I have a feeling that the use of these two is not entirely consistent.

Regards
Henrik

Andres Kroonmaa wrote:

> ok,
>
> Any good reason why we insist on size to be exactly size of
> pool's obj_size?
>
> /* free buffer allocated with memAllocBuf() */
> void
> memFreeBuf(size_t size, void *buf)
> {
> int i;
> MemPool *pool = NULL;
> assert(size && buf);
> for (i = 0; i < mem_str_pool_count; i++) {
> if (size <= StrPoolsAttrs[i].obj_size) {
> >>> assert(size == StrPoolsAttrs[i].obj_size);
> pool = StrPools[i].pool;
> break;
> }
> }
> memMeterDec(StrCountMeter);
> memMeterDel(StrVolumeMeter, size);
> pool ? memPoolFree(pool, buf) : xfree(buf);
> }
>
> ------- End of forwarded message -------
>
> ------------------------------------
> Andres Kroonmaa <andre@online.ee>
> CTO, Microlink Online
> Tel: 6501 731, Fax: 6501 725
> Pärnu mnt. 158, Tallinn,
> 11317 Estonia
Received on Mon Oct 08 2001 - 09:54:35 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:26 MST