cURL / Mailing Lists / curl-users / Single Mail


Re: Problem with strdup

From: Eric VERGNAUD <>
Date: Sat, 18 Dec 2004 13:48:52 +0100

le 18/12/04 11:21, Daniel Stenberg à a écrit :

> On Fri, 17 Dec 2004, Eric VERGNAUD wrote:
>> Now I have the proof that the comment is write.
> I consider this a problem in your end. libcurl is a library written in C and
> it uses numerous libc-functions. If your libc provides a flawed version of
> strdup(), then I think you should fix your libc.
> We could possibly write a configure test that tests your particular strdup()
> version to see if it is OK to free() or not, but it sounds like it would be
> far from failsafe.
> Let me quote from the Linux strdup() man page:
> 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.

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).

Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
Received on 2004-12-18