Returning string from dll - memory leak?
From: Anders Thomsen (junk_at_mexp.dk)
Date: 04/30/04
- Next message: Rob Williscroft: "Re: Pointer to Class prb"
- Previous message: Jeff Schwab: "Re: Pointer to Class prb"
- Next in thread: Jeff Schwab: "Re: Returning string from dll - memory leak?"
- Reply: Jeff Schwab: "Re: Returning string from dll - memory leak?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Apr 2004 13:11:49 +0200
Hi,
I'm trying to return a string from a c++ dll in a method I load from VB.NET.
This is the method is defined like this:
extern "C" __declspec(dllexport) LPSTR GetData(BSTR hostExport, int
portExport)
The code I use for returning the string is this:
...
LPSTR lpReturnStr;
lpReturnStr = (LPSTR)malloc(strlen(csRef) + 1); //csRef is a CString
strcpy(lpReturnStr, csRef);
return lpReturnStr;
My question is, if the second line will cause a memory leak, as I do not
manually release the memory created by malloc.
Does the caller (in this case, the VB.NET application) free the string, or
should I do this in an other way?
Thanks
- Next message: Rob Williscroft: "Re: Pointer to Class prb"
- Previous message: Jeff Schwab: "Re: Pointer to Class prb"
- Next in thread: Jeff Schwab: "Re: Returning string from dll - memory leak?"
- Reply: Jeff Schwab: "Re: Returning string from dll - memory leak?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|