-------- Original Message --------
Subject: Add the rl_free(void *buff) function to the readline library
Date: Wed, 01 Nov 2006 12:47:38 +0100
From: Borut Razem <borut.razem@...>
To: bug-readline@..., chet.ramey@...
I suggest to add the rl_free(void *buff) function to the readline library.
The function rl_free() should be used instead of free() to deallocate
the buffer returned by readline(), the buffer passed as the parameter to
lhandler function installed by rl_callback_handler_install() and buffers
allocated by readline library functions (history_expand(),
It is always recommended to free the memory by the same module that
allocated it. This fact becomes more evident when the module is
dynamically linked: the main program and the shared library may use
different memory allocation libraries, which might be problematic if the
memory is allocated by the shared library and deallocated by the main
I came across this problem when dynamically linking readline.dll,
generated by mingw gcc compiler, from the main program compiled with
Visual Studio .NET: the memory allocation is done by msvcrt.dll called
from readline.dll, while the deallocation is done by msvcr80.dll (or the
statically linked equivalent) called from the main program, which seems
to be incompatible.
I attached the patch which adds the rl_free() function to readline
library and changes free() to rl_free() in examples directory. The
documentation in doc directory should be updated accordingly.
I'm the developer and maintainer of WIN32 port on sdcc
http://sdcc.sourceforge.net/ and gpsimWin32
http://gpsim.sourceforge.net/gpsimWin32/gpsimWin32.html projects, both
using the readline library.
The WIN32 port of readline 5.1 library is available at
P.S.: The http://directory.fsf.org/readline.html page is not updated
with the latest readline 5.2 version.