From: Chris <chr...@gm...> - 2004-11-02 01:47:09
|
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 |