cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Problem with strdup

From: Eric VERGNAUD <eric.vergnaud_at_jlynx.com>
Date: Wed, 22 Dec 2004 16:00:40 +0100

le 18/12/04 23:23, Daniel Stenberg à daniel-curl_at_haxx.se a écrit :

> On Sat, 18 Dec 2004, Eric VERGNAUD wrote:
>
>>> The strdup() function returns a pointer to a new string which is a
>>> duplicate of the string s. Memory for the new string is obtained with
>>> malloc(3), and can be freed with free(3).
>>
>> The problem is that Metrowerk's C library provides its own implementation of
>> malloc and free. I think this is because that C library is meant to compile
>> and link under both MacOS 9 (which has no malloc) and MacOS X.
>
> So it provides malloc and free but not strdup?
>
>> Since libcurl is compiled using gcc, it links with apple's malloc and free
>> while strdup internally calls Metrowerk's free (defined as _sys_free).
>
> I get confused. Why does libcurl use Apple's malloc/free but Metrowerk's
> strdup? The libc provided by Apple has a strdup too, surely?

After recompiling Metrowerks stdlib to use the system's malloc, the problem
is still there.

So I checked every detail and found that my app is not linked with
Metrowerks stdlib, but only with Metrowerk's runtime for C++ (new, delete
and exceptions).

Since I don't have the code for apple's strdup, I'm unable to dig further
and understand what exactly is going on.

So I've reenable my hack. I think it may be worth to acknowledge libcurl
users of the potential problem with curl and Metrowerks codewarrior under
Mac0S.

-------------------------------
Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
web: http://www.jlynx.com
-------------------------------
Received on 2004-12-22