[Freeciv-Dev] Re: malloc warning (PR#842)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On 11 Jul 2001, falk.hueffner@xxxxxxxxxxxxxxxxxxxxxxxx wrote:
> Gaute B Strokkenes <gs234@xxxxxxxxx> writes:
>
>> On Wed, 11 Jul 2001, ChrisK@xxxxxxxx wrote:
>> > CVS 11 JUL 2001 GTK+ Linux i386
>> >
>> > I've got a
>> >
>> > 2: Warning: malloc with size 0 at line 750 of unittools.c
>> > 2: Letzte Mitteilung 2mal wiederholt.
>> >
>> > Reproducible. Savegame is here:
>> >
>> > http://www.enter.de/~c.knoke/bugs/malloc.sav.gz
>> >
>> > Login as chris, start game, terminate client.
>>
>> Please try the following patch (untested):
>
> I don't see the point. What's the problem with allocating 0 bytes?
> It doesn't do any harm.
Wrong. malloc(0) brings you into the land of implementation-defined,
as opposed to undefined, behaviour. Even worse, some mallocs just
crap out anyway. This is why fc_malloc() guards against this case,
and gives a warning.
Usually malloc'ing zero bytes is indicative of a thinko of some sort,
so it is useful to give a warning. My patch just avoids the warning.
--
Big Gaute http://www.srcf.ucam.org/~gs234/
GOOD-NIGHT, everybody.. Now I have to go administer FIRST-AID
to my pet LEISURE SUIT!!
|
|