On Tue, 29 May 2007 15:51:10 -0400 Giel van Schijndel 
<[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] schreef:
>> For sound crash on double quit (not always crash), the problems 
>is 
>> that psObj is destoryed before the sound code get chance to 
>> play/remove it.
>> So psObj is pointing to nothing, but psSimpleObj->type (which is 
>
>> psObj) points to area of memory that has been freed.  It then 
>crash.
>>
>> How to fix this?  We have to make sure sound is removed before 
>> psObj is out of scope.  
>>
>> Anyone know where psObj is killed off?  I know there is no 
>> free(psObj) that would be too easy to find. ;)
>>   
>psObj is some kind of droid; psObj is never used by the sound code
>itself, instead it is passed to a callback function.
>
>I think that the best/easiest solution would be to simply drop the
>callback support. All it currently does is calling a given 
>function with
>that psObj pointer upon finishing of playback from one sound 
>effect.
>> Devurandom in rev 1101, in heap.c, you change FREE & MALLOC to 
>free 
>> & malloc, but you no set what is free to NULL.  You also do not 
>set 
>> malloc memory to 0.  This could be cause of more errors, since 
>lots 
>> code expect this.
>> This my understanding of what FREE & MALLOC macro did before.
>>   
>Actually this probably _will_ be the cause of errors (as 
>devurandom
>pointed out when he changed that). The fix however is _not_ to 
>revert
>back to previous behaviour. Since depending on malloc calls to 
>return
>zero-initialized memory, or free calls to set the pointer to NULL 
>is
>very, very bad programming style.
>
in aud.c, line 70,      /* check projectiles */
        if ( psSimpleObj->type == OBJ_BULLET )
....
so sound code checks if psObj fired bullet.   I am no sure I 
understand how remove of callback will help here.
I am look to see how older sound code worked this out.

Why that very bad programming style?  Once you free pointer, how 
else you know it free if no set to NULL?  The malloc memory being 
zero out is also standard from projects I have seen.

--
Click here for fast, free health insurance quotes.  Low rates - great deals 
nationwide.
http://tagline.hushmail.com/fc/CAaCXv1QUc4KPCkKfCzQhDRiNargTZtQ/



_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to