Re: Compile Error

From: WA Support <support@dont-contact.us>
Date: Mon, 29 Sep 2003 12:24:18 -0700

Hello,

Robert Collins wrote:

> code in squid cannot use alloc, malloc, calloc, or free. They must use
> xalloc, xcalloc, xfree, or mempools, or cbdata.
> These wrappers help prevent common allocation bugs, as well as
> introducing refcounting, slab allocation and the like (depending on
> which specific thing is used).
>

Sorry about my ignorance here, but I don't understand how to wrap the
MySQL header, my_alloc.h, so it can be used in squid code. Also, I am
not sure how to use cbdata with my_alloc.h. I have read what
documentation I can find on cbdata, but I am still not clear. I have
also looked at List.h, but can't figure out how cbdata is being used.
At least not with respect to modifying my_alloc.h.

I hate to be such a bother here, but could you please give me an example
of how to wrap my_alloc.h or use cbdata with it?

I have included code for my_alloc.h down to the 'offending line':

/*
   Data structures for mysys/my_alloc.c (root memory allocator)
*/

#ifndef _my_alloc_h
#define _my_alloc_h

#define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10

typedef struct st_used_mem
{ /* struct for once_alloc (block) */
  struct st_used_mem *next; /* Next block in use */
  unsigned int left; /* memory left in block */
  unsigned int size; /* size of block */
} USED_MEM;

typedef struct st_mem_root
{
  USED_MEM *free; /* blocks with free memory in it */

<snip>

I also have the code for my_alloc.c if that would be helpful.

I just don't know where to go from here, so please excuse my flailing.

Thanks,
Murrah Boswell
Received on Mon Sep 29 2003 - 13:21:37 MDT

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