[Freeciv-Dev] Re: [FreeCiv-Cvs] rfalke: Add a "x = NULL;" after a "free(
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, Feb 24, 2002 at 12:55:58PM -0500, Jason Short wrote:
> freeciv@xxxxxxxxxxxxxxxxxxx wrote:
> > This is an automated notification of a change to freeciv cvs,
> > on Sun Feb 24 03:50:34 PST 2002 = Sun Feb 24 11:50:35 2002 (GMT)
> > by Raimar Falke <rf13@xxxxxxxxxxxxxxxxxxxxxx>
> >
> > ---- Files affected:
> >
> > freeciv/client attribute.c climisc.c clinet.c control.c goto.c helpdata.c
> > packhand.c tilespec.c
> > freeciv/client/agents cma_core.c
> > freeciv/common inputfile.c nation.c player.c registry.c shared.c
> > freeciv/server citytools.c gamehand.c gotohand.c mapgen.c plrhand.c
> > sernet.c unithand.c unittools.c
> >
> > ---- Log message:
> >
> > Add a "x = NULL;" after a "free(x);". This will avoid unintentional
> > de-referencing of the pointer.
>
> Wasn't there a discussion before about a function
>
> void fc_free(void** ptr)
> {
> free(*ptr);
> *ptr = NULL;
> }
>
> ?
>
> Seems like using such a construct would make such things easier in the
> future.
I have thought about
#define fc_free(x) free(x); x=NULL;
but this wouldn't solve it. Your version could. Checking the code I
notices that most of the frees already had the "=NULL". So I think the
code is in a good shape in this area.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
BSD: Are you guys coming or what?
|
|