delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/20/04:10:06

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: Troy Noble <troy DOT noble AT channelpoint DOT com>
Cc: "'Christian Lescher'" <christian AT lescher DOT de>, cygwin AT cygwin DOT com,
christian DOT lescher AT icn DOT siemens DOT de
Subject: Re: DLL function with string result?
References: <8F23E55D511AD5119A6800D0B76FDDE11E0F41 AT cpex3 DOT channelpoint DOT com>
From: Andrew Markebo <flognat AT flognat DOT myip DOT org>
Date: 20 Apr 2001 10:08:27 +0200
In-Reply-To: <8F23E55D511AD5119A6800D0B76FDDE11E0F41@cpex3.channelpoint.com>
Message-ID: <m37l0gro1w.fsf@master.athome>
Lines: 28
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7
MIME-Version: 1.0

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 DOT noble AT channelpoint DOT 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

- Raw text -


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