delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/20/12:27:25

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
To: Christian Lescher <christian AT lescher DOT de>
Cc: cygwin AT cygwin DOT com
Subject: Re: AW: DLL function with string result?
References: <4 DOT 3 DOT 1 DOT 2 DOT 20010420103953 DOT 022a2700 AT pop DOT ma DOT ultranet DOT com>
<3AE05CFF DOT 9D92E32F AT lescher DOT de>
From: Andrew Markebo <flognat AT flognat DOT myip DOT org>
Date: 20 Apr 2001 18:21:23 +0200
In-Reply-To: <3AE05CFF.9D92E32F@lescher.de>
Message-ID: <m3oftrr18c.fsf@master.athome>
Lines: 29
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7
MIME-Version: 1.0

/ Christian Lescher <christian AT lescher DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019