I've got a question which is hopefully a very simple one: I have an
unmanaged DLL which has abstracted the memory management such that I
can supply the malloc and free methods.
(ie)
void __nogc * pascal myMalloc (struct tag_MemoryStream __nogc * pX,
size_t cb) ;
void pascal myFree (void __nogc * pX, void *ptr) ;
... I'd like to implement these methods such that I create and return a
managed array which is not GC'ed (ie GC::KeepAlive()) and returned,
then when myFree is called, I'd like to convert this back again (ie
GC::ReRegisterForFinalize( bytes )). Does anyone have an idea of how
to best go about this in managed C++?
Mattias Sj?gren - 15 Feb 2005 06:11 GMT
>Does anyone have an idea of how
>to best go about this in managed C++?
You can use GCHandle to pin the array and retreive the pointer.
GC::KeepAlive and GC::ReRegisterForFinalize will not help you here.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.