Dennis Schridde schreef:
> Am Mittwoch, 13. Juni 2007 schrieb [EMAIL PROTECTED]:
>
>> I no could tell where original function came from. It was add to
>> tex.c from ???
>> It crash for me with free memory already free.
>> So this fix it.
>>
>> Also, I find that lots physfs routines that use copy, use uninit
>> variables, but no seem to be problem?
>>
> You mean we pass variables to i.e. PhysFS which then copies something into it?
> This should be ok in case the PhysFS docs don't say otherwise.
> Personaly I initialize every var on declaration, to prevent me from
> forgetting
> it in important places and to prevent such messages from eg. valgrind, but I
> don't know what others think about this...
>
My opinion is this: don't use a variable's value until it is first
written to. This could be much easier enforced if we would _not_ have to
declare variables at the beginning of each block but at the first point
where we need it (i.e. to write to it).
>> Index: tex.c
>> ===================================================================
>> --- tex.c (revision 1494)
>> +++ tex.c (working copy)
>> @@ -264,7 +264,7 @@
>>
>> void iV_unloadImage(iV_Image *image)
>> {
>> - if (image)
>> + if (image->bmp)
>> {
>> free(image->bmp);
>> image->bmp = NULL;
>>
> The idea of this if was probably to check whether we got passed a NULL
> pointer, not to check whether bmp was allready freed.
> I don't know what ISO-C says, but I would guess that it is legal to call free
> on a NULL pointer... Am I wrong about this?
>
free(NULL) is very much legal yes. It should be similar to a no-op. If
image is NULL however, then you're dereferencing a NULL pointer to
receive the bmp pointer, which is _not_ legal.-- Giel
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Warzone-dev mailing list [email protected] https://mail.gna.org/listinfo/warzone-dev
