[SDL] Problem with reusing array of surfaces.
David Olofson
david at olofson.net
Fri May 9 08:15:01 PDT 2003
On Friday 09 May 2003 16.43, David Olofson wrote:
> On Friday 09 May 2003 16.05, Sweeney, Steven (FNB) wrote:
> [...]
>
> > 3. Calling,
> >
> > if (image[0] == NULL)
> >
> > and image[0] was never set to NULL to begin with will / might
> > cause seg faults.
>
> Have you actually seen this happen on anything like a PC or
> workstation CPU? It takes a rather weird architecture to segfault
> by just checking the value of a pointer... The problem is that the
> NULL test thinks any garbage is a valid pointer.
Of course, that's probably exactly what you meant... :-)
> Either way, I'd write (NULL == image[0]) instead, just in case '=='
> accidentally becomes '='. I think you can also assume that NULL ==
> 0 on any architecture currently in use, so you can just do
> if(image[0]) ...; to avoid that problem entirely.
...and "if(NULL == image[0])" would become "if(!image[0])", obviously.
I should probably not try to do anything important until my fever gets
a bit better. Can't think straight. (Well, I mean, it's harder than
usual. ;-)
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -'
--- http://olofson.net --- http://www.reologica.se ---
More information about the SDL
mailing list