Re: [AD] More asserts

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Saturday 30 August 2003 5:44 pm, Jon Rafkind wrote:
> Attached are some asserts for graphics.c and quat.c. ASSERT seems necessary
> when the pointer in question is necessary for the function to continue.
> Some functions in graphics.c need the system_driver, but only for one line.
> At these times, I added an extra if clause and not ASSERT( system_driver ).
> I wasnt sure if system_driver is gauranteed to exist or not, but I saw an
> ASSERT in another function and decided to go through and add the rest.

Do you know what ASSERT is for? It's for use with conditions that will always 
be true unless the programmer makes a mistake. When the code is compiled with 
-DDEBUGMODE=1 (as is the case with the debugging build of the library), the 
check will be made and if the condition evaluates false then the program will 
abort. In the optimised build, the check is not made.

So, instead of adding a clause, you should add an ASSERT - unless it is valid 
for the condition to be false at that point in the program. In this case I 
imagine it is not, since allegro_init() or install_allegro() will set 
system_driver and nothing else (with one or two documented exceptions) should 
be called first.

Ben





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/