Re: [AD] Font drawing bug

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


On 8 Aug 2008, at 19:44, Milan Mimica wrote:
On linux, memset() is usually a much more expensive operation than malloc(), because it's at memset() that the memory is actually allocated by the kernel.

Immaterial in this case, since at some point you will use the memory allocated to the sprite anyway. Either immediately (by clearing it explicitly) or afterwards.

Say you have a C++ class which contains several bitmaps which are created in
constructor, but not filled until some method is called.

You mean, not until some method that is not part of the initialisation? Otherwise it wouldn't matter.

Or when you load sprites and you don't need the bitmap to be cleared.

That's the situation I was thinking of where you don't care about the bitmap being cleared or not.

The only situation where you want the bitmap to be cleared is when you draw your
own sprite from the code.

When you do your own manipulation of the bitmap. Slight difference in emphasis. In a sense it's the reverse of the previous point: unless you load some data into the bitmap anyway, you'll want to have it cleared. You could argue that in a game, the normal operation is to load data from disk so you don't care. Besides, it's easy to tell the user to clear the bitmap before using it if they want to use it.
In a sense it's the difference between using malloc() and calloc().

Which actually raises a question: what does Allegro 4.2 do when you allocate a bitmap? Is it guarenteed to be initialised to all 0? I have a recollection of this not being the case at some point in the distant past (it might have been with Allegro 3.11), which has lead me to the habit of always clearing it myself after create_bitmap().

Evert




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