I would like to use Allegro'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.
Is there any plan for allowing the user of A5 to use the same functions for memory management?
Your homepage is broken, but that's not the question :-p
What are you calling memory management ? I've never heard of it before.
A5 contains a function to set the memory management functions:
void al_set_memory_management_functions( void *(*malloc)(void *opaque, size_t size), void *(*malloc_atomic)(void *opaque, size_t size), void (*free)(void *opaque, void *ptr), void *(*realloc)(void *opaque, void *ptr, size_t size), void *(*debug_malloc)(int line, const char *file, const char *func, void *opaque, size_t size), void *(*debug_malloc_atomic)(int line, const char *file, const char *func, void *opaque, size_t size), void (*debug_free)(int line, const char *file, const char *func, void *opaque, void *ptr), void *(*debug_realloc)(int line, const char *file, const char *func, void *opaque, void *ptr, size_t size), void *user_opaque);
I'd like to have access to these functions in my A5 library.
My homepage is under construction.
That only changes the functions Allegro uses internally to do its management.
I think the plan was to expose them with al_malloc and al_free. Nobody made a patch for it so far though.
I also wonder what the "_atomic" means in this context.
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.
Perhaps expose them as the functions themselves? Like al_malloc etc.
That only changes the functions Allegro uses internally to do its management.
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' routines.
I also wonder what the "_atomic" means in this context.
A block without pointers. It is a terminology coming from garbage collection. It's nice that A5 specifies this, because memory management functions can be set to gc_malloc/gc_malloc_atomic (of the Boehm GC collector).
I see. Should be documented then.
I see. Should be documented then.
I'm not sure thats what it actually means...
Even more a reason to document it (by whoever knows what it means)
And currently addons are free to use the AL_MALLOC/AL_FREE macros from aintern_memory.h iirc. I have anyhow.
Is it AL_MALLOC, AL_FREE or al_malloc, al_free?
Neither. It currently is _AL_MALLOC/_AL_FREE, but that's for Allegro internal use only (and addons). al_malloc/al_free are planned to be added.
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.
What does allegro do in al_mallc/al_free that's so special?
It calls the appropriate malloc/free functions set by the function 'al_set_memory_management_functions'.
This is important for debugging.
Its important for systems that provide entirely different memory managers for Apps and DLLs (*cough*windows/msvc*cough*).
Passing in the application's memory management functions to Allegro, and all addons using those means everyone is using the same memory manager, and address space.