<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] access to memory management API?</title>
		<link>http://www.allegro.cc/forums/view/599519</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 12 Mar 2009 19:44:30 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would like to use Allegro&#39;s memory API in my program, however the docs do not specify any functions for memory management; only a function for setting the internal functions is specified.</p><p>Is there any plan for allowing the user of A5 to use the same functions for memory management?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 10 Mar 2009 20:22:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Your homepage is broken, but that&#39;s not the question :-p</p><p>What are you calling memory management ? I&#39;ve never heard of it before.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 10 Mar 2009 20:27:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A5 contains a function to set the memory management functions:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> al_set_memory_management_functions<span class="k2">(</span>
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_551.html" target="_blank">malloc</a><span class="k2">)</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>opaque, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span>malloc_atomic<span class="k2">)</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>opaque, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k2">(</span><span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_350.html" target="_blank">free</a><span class="k2">)</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>opaque, <span class="k1">void</span> <span class="k3">*</span>ptr<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_648.html" target="_blank">realloc</a><span class="k2">)</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>opaque, <span class="k1">void</span> <span class="k3">*</span>ptr, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span>debug_malloc<span class="k2">)</span><span class="k2">(</span><span class="k1">int</span> <a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a>, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>file, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>func,
      <span class="k1">void</span> <span class="k3">*</span>opaque, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span>debug_malloc_atomic<span class="k2">)</span><span class="k2">(</span><span class="k1">int</span> <a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a>, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>file, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>func,
      <span class="k1">void</span> <span class="k3">*</span>opaque, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k2">(</span><span class="k3">*</span>debug_free<span class="k2">)</span><span class="k2">(</span><span class="k1">int</span> <a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a>, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>file, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>func,
      <span class="k1">void</span> <span class="k3">*</span>opaque, <span class="k1">void</span> <span class="k3">*</span>ptr<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span><span class="k2">(</span><span class="k3">*</span>debug_realloc<span class="k2">)</span><span class="k2">(</span><span class="k1">int</span> <a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a>, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>file, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>func,
      <span class="k1">void</span> <span class="k3">*</span>opaque, <span class="k1">void</span> <span class="k3">*</span>ptr, size_t size<span class="k2">)</span>,
   <span class="k1">void</span> <span class="k3">*</span>user_opaque<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

I&#39;d like to have access to these functions in my A5 library.</p><p>My homepage is under construction.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 10 Mar 2009 20:44:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That only changes the functions Allegro uses internally to do its management.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Tue, 10 Mar 2009 20:47:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the plan was to expose them with al_malloc and al_free. Nobody made a patch for it so far though.</p><p>I also wonder what the &quot;_atomic&quot; means in this context.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 10 Mar 2009 20:51:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I too think having a way to access these functions would be useful: for example, the addons can be made to use them too, which seems good in my mind.</p><p>Perhaps expose them as the functions themselves? Like al_malloc etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 10 Mar 2009 20:52:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That only changes the functions Allegro uses internally to do its management.
</p></div></div><p>

Indeed, but here is a scenario: the user that uses A5 and external libraries based on A5 will have a hard time debugging his/her app when it comes to memory management, because the external libraries will not use A5&#39; routines.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I also wonder what the &quot;_atomic&quot; means in this context.
</p></div></div><p>

A block without pointers. It is a terminology coming from garbage collection. It&#39;s nice that A5 specifies this, because memory management functions can be set to gc_malloc/gc_malloc_atomic (of the Boehm GC collector).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 10 Mar 2009 20:55:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I see. Should be documented then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 10 Mar 2009 21:01:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I see. Should be documented then.
</p></div></div><p>I&#39;m not sure thats what it actually means...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 11 Mar 2009 01:41:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Even more a reason to document it (by whoever knows what it means) <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 11 Mar 2009 01:50:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And currently addons are free to use the AL_MALLOC/AL_FREE macros from aintern_memory.h iirc. I have anyhow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 11 Mar 2009 01:53:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is it AL_MALLOC, AL_FREE or al_malloc, al_free?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 11 Mar 2009 17:58:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Neither. It currently is _AL_MALLOC/_AL_FREE, but that&#39;s for Allegro internal use only (and addons).  al_malloc/al_free are planned to be added.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Wed, 11 Mar 2009 18:11:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok...thanks. I will use al_malloc, al_free in my project, which will be a macro for _AL_MALLOC, _AL_FREE. When the memory API will be available, I will remove the macros.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 11 Mar 2009 18:24:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What does allegro do in al_mallc/al_free that&#39;s so special?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 12 Mar 2009 01:03:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It calls the appropriate malloc/free functions set by the function &#39;al_set_memory_management_functions&#39;.</p><p>This is important for debugging.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Thu, 12 Mar 2009 14:39:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Its important for systems that provide entirely different memory managers for Apps and DLLs (*cough*windows/msvc*cough*).</p><p>Passing in the application&#39;s memory management functions to Allegro, and all addons using those means everyone is using the same memory manager, and address space.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 12 Mar 2009 19:44:30 +0000</pubDate>
	</item>
</rss>
