Re: [AD] About create_bitmap |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Thu, 2004-11-04 at 03:37 -0800, Chris wrote:
> On Thu, 04 Nov 2004 20:15:57 +1100, Peter Wang <tjaden@xxxxxxxxxx> wrote:
> > This is still a bad idea if you're not sure about the numbers you
> > obtained. You might have code that "works" in release mode, but not in
> > debug mode (as it shouldn't). Or do you mean to get rid of the ASSERTs
> > completely and replace them with if's?
>
> Well, I think it's best to just replace them with if()'s. As far as
> I'm concerned, code should not crash (or ASSERT) unless given
> unhandlable parameters (or if it's a speed-critical function and you
> want to reduce code for release mode). create_bitmap(_ex) is not
> speed-critical and negative sizes can be detected easy enough, and the
> function can return an error (NULL).
Yes. Maybe I'm just used to handle all of this with ASSERT. My main
concern is, why then not have if (bmp == NULL) in putpixel? You can
never tell which functions are time critical enough to not have such a
check. blit() certainly wouldn't be affected by a single if. Allegro's
way was to use ASSERT for every parameter checking, which is a simple
and effective way in my opinion.
>
> Besides, letting a function crash can wreak havoc on the rest of the
> system (for certain systems), and I think we should avoid that when
> possible. The docs say that the functions return NULL if the bitmap
> can't be made, but say nothing about crashing/asserting on negative or
> 0 values (where one would logically assume the function would just
> return NULL because a bitmap of such a size can't be made).
>
That's why we have ASSERT.
Anyway, using ASSERT a lot might just be my personal coding style (I use
it a lot in my own code, and hardly ever compile something in release
mode) - and this helps a lot with testing. But, well, for create_bitmap,
it really doesn't matter much. I don't think I ever passed wrong values
to it..
--
Elias Pschernig