This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: AW: DLL function with string result?


/ Christian Lescher <christian@lescher.de> wrote:
| > Yes, there is a general problem when you want to allocate in one DLL made
| > by one compiler and de-allocate in another built be another compiler.  In
| > this case, the heaps are different.  This is not a Cygwin-specific issue.
| 
| I see. Would it be possible then to define a second function within the DLL, let's say freeStr(const char* resStr) which releases the memory
| again?

Yes I think that is the way to do it, thats how we solved the problem
between borland and microsoft compiled code.

| And should Troy Noble's code then work for strings > 64 KB, too? (Currently, I get an access violation, even when not freeing the allocated
| memory outside the DLL.)

Is it the code below that dies Which compiler does what in this
scenario?? Could it be some difference between how cygwin and
microsoft handles strings, 64kB smells like some magic limit of some
kind :-)

Have you tried doing the copy yourself? byte by byte??

        /Andy

| char*
| mallocAndStrCpy (const char* srcStr) {
|    if (srcStr == NULL)
|       return NULL;
|    return strdup(srcStr);
| }

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]