Re: cloning at the interface level?
On Aug 1, 1:12 am, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
On 2008-08-01 00:54, DomoC...@gmail.com wrote:
Please quote the text you are replying to.
Actually I just want to transfer ownership. I have a file
loading subsystem, and a resource storage subsystem ( these
are separate dll's if it matters ). the data is
instantiated within the loader, and should be transferred to
storage. I actually tried to virtual clone method
yesterday, and I could have sworn it didnt work, I just
tried it again, and works perfectly : ) But, is there a
way to say some memory belongs to another process?
If all you need to do is to transfer ownership then simply
storing the pointer might work, note though that you might not
be able to deallocate the memory they point to in any other
DLL than the one you allocated it it, but that could be solved
by exporting a function you can call. The advantage of such a
scheme is that you do not have to pay the overhead of copying
all the INode objects.
Well, the standard doesn't say anything about DLL's, so
technically, it's implementation defined. But in practice, I've
never had any problems with it (although you have to be careful
how you link under Windows).
Note that different DLLs are not the same thing as different
processes, (and that neither of those things are on topic in
this group, a Windows group might be a better place). You
might however be able to create a third, shared heap in which
both DLLs may allocate and deallocate.
According to the collegues here who develope under Windows,
there's a simple way to make malloc (and thus new) use a shared
heap, at link time. (I think it involves linking against a C
runtime which puts malloc/free in a shared library, but I'm not
too sure.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34