Re: Passing pointer between DLL boundary question
Hi Ali,
You're right of course, but I think it is dangerous to allocate memory and
count on the calling routine to free (or delete) it. I would tend to create
my own object or objects and then deallocate them automatically in a
destructor or some deinitialization code. Passing in a buffer is also
problematic as the size will have to be known. Since the OP is using MFC
passing in something like a reference to an object that resizes itself (like
a CString) might make more sense.
That said, I probably have an strdup() in my code somewhere or another ...
Tom
"AliR" <AliR@online.nospam> wrote in message
news:44bd2f9f$0$23762$a8266bb1@reader.corenews.com...
The answer to your question is it doesn't matter where it gets created and
where it gets deleted. As long as it is deleted properly. And as long as
the users of your code know that when they call a function that creates
the
buffer, they have to delete the buffer themselves.
You can create the buffer in the dll, and delete it in the exe, or create
it
in the exe and delete it in the dll.
AliR.
<indrawati.yahya@gmail.com> wrote in message
news:1153247899.764220.70200@h48g2000cwc.googlegroups.com...
No answer to my original question? :(