Re: [GD-Windows] new/delete across DLL's
Brought to you by:
vexxed72
From: Javier A. <ja...@py...> - 2003-03-24 18:33:48
|
If both the EXE and your DLL link with the MSVC DLL runtime, it will work correctly because all allocations are physically performed inside the (single instance of the) runtime DLL. Rich wrote: > >> 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. Javier Arevalo Pyro Studios |