Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [patches] freeing NULL ptrs
Home

[Freeciv-Dev] Re: [patches] freeing NULL ptrs

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Justin Moore <justin@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [patches] freeing NULL ptrs
From: Kevin Brown <kevin@xxxxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 21:50:47 -0700

Justin Moore <justin@xxxxxxxxxxx> wrote:
> 
>    More of the same.  All these patches can also be grabbed from
> http://opus.dulug.duke.edu/~justin/public/FreeCiv/
> 
> > > PS. Would it be worth it to create a fc_free that ignores all NULL
> > > pointers passed to it?
> >
> > Probably.  It might be helpful, too, to have that same function
> > assert(ptr != NULL) first if compiled with debugging turned on, so
> > that any instances where the code tries to free a NULL can be tracked
> > down and, if necessary, fixed.
> 
>    The patch defining this function is included.  It'll be quite a series
> of patches to switch everyone from using free() to fc_free(), though. :)

One comment: it looks like handle_free_failure will always drop core
unless the assert() is nooped out by defining NDEBUG (which also
happened to break other things as of 1.11.4.  Haven't looked at the
current sources to see if that remains the case).  I'd say if you put
the assert() within an #ifdef DEBUG block then you'll be all set.


-- 
Kevin Brown                                           kevin@xxxxxxxxxxxxxx

    It's really hard to define what "unexpected behavior" means when you're
                       talking about Windows.


[Prev in Thread] Current Thread [Next in Thread]