Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load
Home

[Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bh@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load
From: "Ben Webb" <ben@xxxxxxxxxxx>
Date: Wed, 19 Nov 2003 00:20:06 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >

On Tue, Nov 18, 2003 at 01:33:35PM -0800, Benoit Hudson wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >
> 
> On Tue, Nov 18, 2003 at 01:17:55PM -0800, Jason Short wrote:
> > That was my thought as well.  But the player array is a *currently* a
> > statically declared array, meaning all its pointers are initialized to NULL.
> >
> > If this change is done, though, a comment should be added to the players
> > array to alert anyone thinking to change it in future.
> 
> That seems like a very bad thing to rely on.  In my experience, whenever
> I rely on something like that it comes out and bites me; so I memset and
> calloc all the time.

You can't (portably) use calloc or memset to initialise pointers to NULL
anyway, since it zeroes memory... and a NULL pointer (or a valid floating
point number, for that matter) is not necessarily represented by all
binary digits 0. See http://www.lysator.liu.se/c/c-faq/c-3.html#3-13

        Ben
-- 
ben@xxxxxxxxxxx                      http://salilab.org/~ben/
"Ice formed on the butler's upper slopes."
        - 'Pigs Have Wings (1952), ch. 5, pt. i', P.G. Wodehouse




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