This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: DLL function with string result?
- To: Troy Noble <troy dot noble at channelpoint dot com>
- Subject: Re: DLL function with string result?
- From: Andrew Markebo <flognat at flognat dot myip dot org>
- Date: 20 Apr 2001 10:08:27 +0200
- Cc: "'Christian Lescher'" <christian at lescher dot de>, cygwin at cygwin dot com,christian dot lescher at icn dot siemens dot de
- References: <8F23E55D511AD5119A6800D0B76FDDE11E0F41@cpex3.channelpoint.com>
Uhm sorry if I missed something here.. are you doing something like
allocating memory in cygwin that is freed on visual, or the other way
around..
I don't think that is a good idea.. At least not when you are using
Visual and Borland, so I guess the same problem might happen with
Visual and cygwin.
/Andy
/ Troy Noble <troy.noble@channelpoint.com> wrote:
| Personally, I'd instead write it as follows:
|
| char*
| mallocAndStrCpy (const char* srcStr) {
| if (srcStr == NULL)
| return NULL;
| return strdup(srcStr);
| }
|
| The caller can use free() on the pointer you return, since the
| DLL runs inside the same process on Win32 and thus shares the
| same global heap for malloc operations. Note that you won't be able
| to modify the "original" pointer passed to you by the caller, so
| the caller will need to make sure they also free(srcStr) at
| some point as well or you'll have a memory leak.
|
[...]
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple