cURL / Mailing Lists / curl-users / Single Mail

curl-users

[ curl-Bugs-610674 ] Inconsistency in memory allocation

From: <noreply_at_sourceforge.net>
Date: Tue, 17 Sep 2002 10:33:42 -0700

Bugs item #610674, was opened at 2002-09-17 10:33
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=610674&group_id=976

Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: Inconsistency in memory allocation

Initial Comment:
libcurl has at least two functions (curl_escape and
curl_unescape), which return a pointer to memory that
libcurl itself is allocating, but it does not provide a
function that libcurl can free this memory.
The documentation says to use free () on the memory
returned.
This is problematic in the general case: It works, if both,
libcurl and the caller use the same underlying memory
management. But it will fail if this is not the case.
One case in which I noticed this problem is with Visual
C++ on Windows98 (I believe that the libcurl dll was
compiled in release mode, while the app was compiled
in debug mode:
In Debug mode, the memory allocator tracks
allocation/de-allocation of memory through a linked list.
Libcurl's memory allocation did not do that. So when a
pointer from libcurl was freed in the app, the memory
consistency checker of the app throws assertions.

The solution to this issue is to provide a void curl_free
(void*).

More specifically:
Add curl_free () declaration in header file curl.h
Add curl_free () implementation inton source file
escape.c(?)
add curl_free () into the dll def file (as last entry, so that
previous versions fo the dll are compatible)
Update documentation to say that curl_free () should be
used for memory that has been allocated by curl.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=610674&group_id=976

-------------------------------------------------------
This SF.NET email is sponsored by: AMD - Your access to the experts
on Hammer Technology! Open Source & Linux Developers, register now
for the AMD Developer Symposium. Code: EX8664
http://www.developwithamd.com/developerlab
Received on 2002-09-17