Skip to main content
gamedev.net
🔒 Locked

Intergating Memory allocator into project

Started by SW INC Sep 26, 2005 at 11:42 PM 3 replies 950+ views
Original Post
SW INC
SW INC
i've been trying to think up ways to integrate my memory allocator into 3rd party libraries that i use in my main program i have the global new, new[], delete and delete[]s all overloaded and c-syle malloc, calloc, realloc, and free that all allocate memory from a global pool now i need to link this system into the memory allocators of Ogre, Lua, TrueAxis, and Raknet tall order there Ogre is in a dll the others are in static libs (will use TA and RakNet dlls after debugging) ogre and TrueAxis both have their own overloaded news the only way i can think of integrating them is to manually code their memory managers to accept pointers to my c-style allocators and pass it all in is there any way to force them to use MY overloaded gloabal new/delete? or is there something else that can be done? im just not sure what else i can do im using c++ on devcpp (as if that will help) ps any one interested in using/seeing/laughing at the allocator i have (build on code in public domain) just ask
Leadorn
Leadorn
Hi

I don’t think it’s possible because within the dll function calls are already linked to its copy of the CRT.

Well im no expert in this area so I might be wrong.


I know u don’t want to hear this but why do u need the same heap. Why not return memory allocated by ogre to ogre dll.


Recompile ogre dll, checkout GlobalAlloc()
SW INC
SW INC
will i figured as much for the precompiled dlls
same for the static libraries as well, the new, delete is not exposed and seems to be linked internally (checked debuging info)

so guess i'll be recompiling everything (joy)

but..
i know how to link/call library code from a application
how could i link/call application code from a library w/o using function callbacks

if i compile functions to allocate memory and link them to each dll i'd have 3 or 4 allocation function all floating around programs code during runtime
is this clear enough to get some help, i have no clue what i need
Evil Steve
Evil Steve
I think your best bet would be to put your allocation functions into a DLL, and get all of the modules to link to that. That'll work in a similar way to the DLL versions of the CRT; all modules will load the one DLL, so you only have one copy of your memory functions loaded. That'll also stop you from running into problems with deleting memory in one module that was allocated in another.
As for Ogre and TA, you might be best modifying the source code to either remove or modify their overloaded operator new and deletes (I don't know if this is possible with TA, but it should be with Ogre), so they call your own allocation functions.
SW INC
SW INC
and if i put my new and delete in a dll the recompiled dlls will use that right

coo, thanks evil steve

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.