<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Destroying bitmaps</title>
		<link>http://www.allegro.cc/forums/view/586425</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 13 Jul 2006 12:15:52 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there any reason that a bitmap should <b>not</b> be destroyed? The reason I ask is because I get a crash when I call destroy_bitmap for some bitmaps. The bitmaps in question are loaded from a datafile, and I&#39;m positive that they aren&#39;t being used after the destroy_* function has been called. I also have the same problem with some fonts, also loaded from a datafile. Not all the bitmaps loaded from the datafile cause a crash when destroyed, though.</p><p>Also, just for reference, in my triple buffering code I do this:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">int</span> on_page <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>active_page<span class="k2">;</span></td></tr><tr><td class="number">4</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>page<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td>...</td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td>page<span class="k2">[</span><span class="n">0</span><span class="k2">]</span> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>page<span class="k2">[</span><span class="n">1</span><span class="k2">]</span> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>page<span class="k2">[</span><span class="n">2</span><span class="k2">]</span> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>    </td></tr><tr><td class="number">12</td><td>active_page <span class="k3">=</span> page<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>&#160;</td></tr><tr><td class="number">14</td><td>...</td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td>on_page <span class="k3">=</span> <span class="k2">(</span>on_page <span class="k3">+</span> <span class="n">1</span><span class="k2">)</span> % <span class="n">3</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>active_page <span class="k3">=</span> page<span class="k2">[</span>on_page<span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td>...</td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td><a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>page<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">22</td><td><a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>page<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td><a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>page<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr></tbody></table></div></div><p>Then all drawing is done to active page. I&#39;m not supposed to call destroy_bitmap for active_page, right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Wed, 12 Jul 2006 00:11:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t destroy a bitmap if:
</p><ul><li><p>It&#39;s loaded from a datafile (load_datafile, load_datafile_object, etc),</p></li><li><p>It still has active sub bitmaps, or</p></li><li><p>The mouse is displayed on it.</p></li></ul><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 12 Jul 2006 00:22:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is there any reason that a bitmap should not be destroyed?
</p></div></div><p>

The most obvious one being... don&#39;t laugh... if you have previously destroyed it or never created it in the first place <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> Destroying a non-existent bitmap will usually result in a crash. In your case you might want to make sure your create_video_bitmap calls aren&#39;t failing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 01:18:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Destroying a non-existent bitmap will usually result in a crash.
</p></div></div><p>

IIRC destroy_bitmap() doesn&#39;t crash on NULL...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CursedTyrant)</author>
		<pubDate>Wed, 12 Jul 2006 01:26:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
IIRC destroy_bitmap() doesn&#39;t crash on NULL...
</p></div></div><p>

It almost always does for me, but I&#39;m not using the very latest version of Allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 01:51:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
IIRC destroy_bitmap() doesn&#39;t crash on NULL...
</p></div></div><p>
Most people don&#39;t NULL their stuff.</p><p>[edit]
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;m not supposed to call destroy_bitmap for active_page, right?
</p></div></div><p>
No, active_page only holds the address to the bitmap, and not the bitmap itself, so you should only destroy page[0], page[1], page[2] when you exit your program.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felipe Maia)</author>
		<pubDate>Wed, 12 Jul 2006 01:53:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It almost always does for me, but I&#39;m not using the very latest version of Allegro.
</p></div></div><p>
As far as I know, it has been valid to pass NULL to destroy_bitmap() since forever. What version of Allegro are you using?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is there any reason that a bitmap should not be destroyed?
</p></div></div><p>
What <i>you</i> allocate, <i>you</i> should free as well.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The reason I ask is because I get a crash when I call destroy_bitmap for some bitmaps. The bitmaps in question are loaded from a datafile,
</p></div></div><p>
The dat entries of a datafile are freed by unload_datafile(). <i>You</i> did not allocate the memory for those bitmaps, so <i>you</i> should not destroy tham.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I also have the same problem with some fonts, also loaded from a datafile
</p></div></div><p>
Same problem.</p><p>If you allocate the object yourself (ie, get it from a function that returns a BITMAP* or a FONT*), then you have to free it. Otherwise you don&#39;t. Think of it this way: you don&#39;t free Allegro&#39;s default font or the screen bitmap either.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 12 Jul 2006 03:00:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Simply calling</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/unload_datafile" target="_blank"><span class="a">unload_datafile</span></a><span class="k2">(</span>datfile<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

should free up all the files you used in the datafile.  I may be wrong but this is always what I do.  Also be sure not to free up a pointer such as active_page.  It only needs to be freed if you actually load a bitmap or a create a bitmap with it. You might also call</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/show_mouse" target="_blank"><span class="a">show_mouse</span></a><span class="k2">(</span>NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
before you free all the memory that way you can be sure the mouse isn&#39;t be displayed.  I could be wrong since I&#39;m still a beginner, but I had the same problems a couple of days ago.  <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paladin)</author>
		<pubDate>Wed, 12 Jul 2006 04:06:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You might also call</p><p>show_mouse(NULL);</p><p>before you free all the memory that way you can be sure the mouse isn&#39;t be displayed.
</p></div></div><p>
Only nescessary if you explicitly call set_gfx_mode() to destroy the screen (assuming that you don&#39;t display the mouse on a different surface, which is generally a silly thing to do).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 12 Jul 2006 11:22:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, that makes sense, thanks guys.</p><p>[EDIT]<br />One more question: if I create sub-bitmaps of a bitmap I loaded from a datafile, do I have to destroy the sub-bitmaps?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Wed, 12 Jul 2006 14:28:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Most people don&#39;t NULL their stuff.
</p></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
As far as I know, it has been valid to pass NULL to destroy_bitmap() since forever. What version of Allegro are you using?
</p></div></div><p>

Sure, but this code seg faults every time for me:</p><p>pseudo code crap below:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>foo<span class="k2">;</span>

<span class="k1">void</span> some_routine<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
.
<span class="c">// We never created the bitmap</span>
.
<a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>foo<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

Right now I think I&#39;m using 4.03.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 17:32:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re just declaring foo, so it has the value that was previously on the memory, which can be anything. Do this not to segfault:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>foo <span class="k3">=</span> NULL<span class="k2">;</span>

<span class="k1">void</span> some_routine<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
.
.
.
<a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>foo<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felipe Maia)</author>
		<pubDate>Wed, 12 Jul 2006 17:34:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Right, that&#39;s what I&#39;m talking about. Guess I was misunderstood earlier in the thread.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 17:37:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Guess I was misunderstood earlier in the thread.
</p></div></div><p>Maybe everyone misunderstood <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /> You&#39;re talking about uninitialized variables being &quot;free&quot;d, while everyone else is talking specifically about passing NULL (or variables set to NULL) to destroy_bitmap. These are two <u>very</u> different things.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 12 Jul 2006 17:39:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s early. I&#39;m not awake yet. Sue me. Regardless, the advice is valid.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 17:42:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Aren&#39;t global uninitialised variables (including Bitmaps) set to NULL? I thought only local variables could hold any value.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Wed, 12 Jul 2006 18:18:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What about bitmap destruction on program exit? I have my bitmaps encapsulated in a Bitmap class (C++) which is destroyed probably after allegro exits. Does allegro destroy its bitmaps automatically on exit?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 12 Jul 2006 18:23:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Does allegro destroy its bitmaps automatically on exit?
</p></div></div><p>
No.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Wed, 12 Jul 2006 18:26:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Then why I can not destroy a bitmap after allegro exits? the program crashes within the destructor of the Bitmap class calling the &#39;destroy_bitmap&#39; function.</p><p>I guess it may be something with allegro cleanup taking place before bitmap destruction. Is there a way to destroy the bitmaps before allegro exits?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 12 Jul 2006 18:28:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Can&#39;t you call the cleanup function before your program ends? Or can you not add with atexit a cleanup function?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Wed, 12 Jul 2006 18:31:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Aren&#39;t global uninitialised variables (including Bitmaps) set to NULL?
</p></div></div><p>it is not quaranteed. I think GCC does that only in debug mode</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I thought only local variables could hold any value.
</p></div></div><p>huh?</p><p>As for cleaning up on program exit, I would simply do something like this:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>Object <span class="k3">*</span>bunc, <span class="k3">*</span>of, <span class="k3">*</span>globals<span class="k2">;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><span class="k1">void</span> init<span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">4</td><td>   intAllegro<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>   initGlobalObjects<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td><span class="k2">}</span></td></tr><tr><td class="number">7</td><td><span class="k1">void</span> run<span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">8</td><td>   <span class="k1">while</span> <span class="k2">(</span>gameGoesOn<span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">9</td><td>      doStuff<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>   <span class="k2">}</span></td></tr><tr><td class="number">11</td><td><span class="k2">}</span></td></tr><tr><td class="number">12</td><td><span class="k1">void</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">13</td><td>   freeGlobalObjects<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td><span class="k2">}</span></td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">17</td><td>    init<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>    run<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td><span class="k2">}</span></td></tr><tr><td class="number">21</td><td><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span></td></tr></tbody></table></div></div><p>I would stay away from non-pointer global objects that have destructors that free allegro objects. The order of destroying objects is not defined and when allegro itself closes before your allegro objects are freed you are screwed. With global pointers you should have no such problems.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 12 Jul 2006 18:48:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">me said:</div><div class="quote"><p>
One more question: if I create sub-bitmaps of a bitmap I loaded from a datafile, do I have to destroy the sub-bitmaps?
</p></div></div><p>Well?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Wed, 12 Jul 2006 18:58:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thinking logically, yes you have to destroy them yourself because you created them.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 12 Jul 2006 19:04:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
One more question: if I create sub-bitmaps of a bitmap I loaded from a datafile, do I have to destroy the sub-bitmaps?
</p></div></div><p>

The general rule is that anything you create, you must destroy.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Wed, 12 Jul 2006 19:05:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes</p><p>[edit]late  <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />but i add this:
</p><div class="quote_container"><div class="title">the manual said:</div><div class="quote"><p>

Return value: Returns a pointer to the created sub bitmap, or NULL if the sub bitmap could not be created. <b>Remember to free the sub bitmap before freeing the parent bitmap to avoid memory leaks and potential crashes accessing memory which has been freed. </b>
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (FMC)</author>
		<pubDate>Wed, 12 Jul 2006 19:07:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I would stay away from non-pointer global objects that have destructors that free allegro objects. The order of destroying objects is not defined and when allegro itself closes before your allegro objects are freed you are screwed. With global pointers you should have no such problems.
</p></div></div><p>

I solved the problem by installing an exit handler which is implicitely installed at first chance (after allegro is initialized).</p><p>I think allegro should have a user-defined shutdown callback which is invoked at &#39;allegro_exit&#39; in order to release any allegro resources at the right time...the exit point of an app can be other than main.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 12 Jul 2006 19:16:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Then why I can not destroy a bitmap after allegro exits?
</p></div></div><p>
Because you cannot call Allegro functions when Allegro is not initialised (either before install_allegro() or after allegro_exit()).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 12 Jul 2006 19:53:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I think allegro should have a user-defined shutdown callback which is invoked at &#39;allegro_exit&#39; in order to release any allegro resources at the right time...the exit point of an app can be other than main.
</p></div></div><p>
Why? If you can just put a function before your program closes, that doesn&#39;t make sense at all. Besides, those aren&#39;t allegro resources, they&#39;re yours resources, you created them, not allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felipe Maia)</author>
		<pubDate>Wed, 12 Jul 2006 19:55:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why would you want to explictly call set_gfx_mode(); to destroy the screen?  Does it destroy every bitmap as well?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paladin)</author>
		<pubDate>Wed, 12 Jul 2006 20:08:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Why? If you can just put a function before your program closes, that doesn&#39;t make sense at all.
</p></div></div><p>

1. exit() might be called at various places.<br />2. It makes my library&#39;s interface simpler.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Besides, those aren&#39;t allegro resources, they&#39;re yours resources, you created them, not allegro.
</p></div></div><p>

Of course. I meant resources managed with allegro i.e. bitmaps/sounds/etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 12 Jul 2006 22:56:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
1. exit() might be called at various places.
</p></div></div><p>If you call exit(), the memory will be freed anyway, there&#39;s no need for that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felipe Maia)</author>
		<pubDate>Thu, 13 Jul 2006 02:30:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Can&#39;t you call the cleanup function before your program ends? Or can you not add with atexit a cleanup function?
</p></div></div><p>

Instead of allegro_init, use install_allegro and pass null for atexit. Then add your atexit handler and at the end of that, call allegro_exit().
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 13 Jul 2006 02:48:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you call exit(), the memory will be freed anyway
</p></div></div><p>
Do not assume this. Even if the OS frees your process&#39;s memory (which it&#39;s not required to do) it may have system resources allocated, which aren&#39;t gauranteed to be freed when a process is closed, because other processes may be able to use it too.</p><p>EDIT:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Instead of allegro_init, use install_allegro and pass null for atexit.
</p></div></div><p>
You can&#39;t do that. IIRC, you must pass a valid atexit handler. What&#39;s so bad about making sure you don&#39;t do Allegro cleanup code in a destructor called after allegro_exit? It&#39;s not hard. Register your own atexit handler after allegro_init that delete&#39;s what you new, and all is well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Thu, 13 Jul 2006 05:16:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Even if the OS frees your process&#39;s memory (which it&#39;s not required to do) it may have system resources allocated, which aren&#39;t gauranteed to be freed
</p></div></div><p>
A good example of this would be video bitmaps in Windows. I understand that this is better now, but it used to be so that these weren&#39;t released automatically.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Thu, 13 Jul 2006 12:15:52 +0000</pubDate>
	</item>
</rss>
