Re: Memory Wrapper

From: Sammy (samedi@DHC.NET)
Date: 05/21/98

On Thu, 21 May 1998, George wrote:

> I shrank it down to 20 bytes for just memory, but decided the whole generic
> attack for memory and buffers was best.  It currently hashes by the size of
> the buffer you request.

Ah I see.

> I changed the CREATE() macro.  I suppose adding more types would be
> possible, and easy.

Yeah grep "CREATE(" *.c | wc -l says I've got 62 instances to look at,
although after giving it some thought, I'm going to have to also change
all strdup's if I want to change all the free's.  It's either that, or
figure out which fre's match the creates and selectively change those to
the new FREE macro.

"Nothing is ever easy."

> I use a generic 'magic_check()' function to validate the buffer.  Currently
> it makes sure the buffer hasn't been overwritten.

I'm using 2 checks, one an immediate check of one pointer, to make sure
it's still valid and hasn't been over written, and the second a check of
all pointers.  I'll probably call that once per game loop, depending on
how long it takes.

> >Is there a portable way to know the current function?
> Not really, but I change __FUNCTION__ to __FILE__ with a #define if not
> using GNU CC. The file and line is enough for my purposes, yours would
> require the extra types.

That may be ok for logging, but passing filename and function to the
manager wouldn't be very useful for determining memory type.  I'll have to
do it all by hand, or at least in the areas where I care.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST