[AD] About create_bitmap

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


I recently ran into this problem when using create_bitmap. Wouldn't it
make more sense to have create_bitmap(_ex) check for valid values (w>0
and h>0) and return NULL if they aren't acceptable rather than
ASSERT'ing? It's not a time-sensitive function so I don't think a
couple if() checks will be a problem. But it becomes a chore when you
have to check manually for >=0 values and if the returned bitmap is
NULL, when more often than not you'd do the same for either error. So
instead of simply doing:

bmp = create_bitmap(w, h);
if(!bmp)
{
   error();
}

you have to do:

bmp = NULL;
if (w > 0 && h > 0)
{
   bmp = create_bitmap(w, h);
}
if(!bmp)
{
   error();
}

Beyond that, create_bitmap_ex allows a width of 0, which will cause a
data allocation size of 0. The bitmap will be created, but once you
try to access the image data.. boom.

- Kitty Cat




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