Re: [GD-Windows] new/delete across DLL's
Brought to you by:
vexxed72
From: Rich <leg...@xm...> - 2003-03-24 18:08:53
|
In article <E18...@sc...>, Ben Hawes <cr...@ca...> writes: > in the game exe, I call wibble =3D new CFooBar; > Later on, within the exe, I call delete wibble; and get an Assert= > warning because I'm deallocating from the wrong heap. Yep. That's the way Windows DLLs work. Allocations inside a DLL are done on the heap belonging to the DLL (because the DLL can live in memory longer than your process, it must use its own heap for allocations). You can deal with it in one of several ways: - use a static library, not a DLL - use a helper function in the DLL that does the deallocation for you I'd use a static library unless there really is some overriding reason to use a DLL. "It just works" that way. -- "The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ: <http://www.xmission.com/~legalize/book/> izfree: Open source tools for Windows Installer <http://izfree.sourceforge.net> |