Re: Medit and Oedit problem in Obuild

From: Gary Barnett (gbarnett@POLARNET.COM)
Date: 09/19/97


On Friday, September 19, 1997 5:30 AM, Sammy [SMTP:samedi@DHC.NET] wrote:
> On Thu, 18 Sep 1997, someone wrote:

<snip>

> I allocate memory with CREATE for test, then allocate memory as needed
> for
> name, then I free name, then free test, for some reason it doesn't seem
> to
> be set to null, so after I free'd test I do a test = NULL, I was
> wondering
> if this was standard behavior ?
>
> THe ANSI C standard doesn't require free to NULL the pointer, so some
> compilers may NULL it, others may leave it alone, allowing you to continue
> to read the data in it, while writing to it is probably going to result in
> a segfault.  If you want it to be set to NULL after a free, you'll have to
> do it yourself.
>

All true, but enter macros :-)

#define FREE(x) (free(x); x=0)

Would that not solve the problem rather nicely? Be easy enough to search
through all your free calls and change them to FREE with a good editor so
that you can remember the difference later. You could redefine free.. but that
could lead to confusion later..

--Mallory

I can picture in my mind a world without war, a world without hate.
And I can picture us attacking that world, because they'd never
expect it.     - Jack Handey


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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