bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] history cleanup question


From: Chet Ramey
Subject: Re: [Bug-readline] history cleanup question
Date: Sat, 04 Feb 2012 15:00:18 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 1/30/12 4:42 PM, Jalil Karimov <address@hidden> wrote:
> 
> Hi Chet,
> 
>     I got a rid of leaks, by doing it myself,
>     after a bit of digging in code, rather than relying on
>     remove/clear_history by doing so:
> 
>     HIST_ENTRY **list = history_list();
>     for (i = 0; list[i]; i++)
>         free list[i]'s line/timestamp/data
>         free list[i]
>     free list
> 
>     valgrind reports no leaks afterwards.

If this works for you, great, but don't use it anywhere but at the end
of a program, and don't try to call readline() after calling it.  The
`data' in the history list is private to readline, and readline keeps
aliases to it.  Freeing memory without accounting for these aliases may
lead to references to that freed memory, which will often cause a program
to crash.

If doing this results in no leaks, though, you're not using the term
as it's commonly used.  These `leaks' are simply memory that is still
allocated at program exit.  There are no instances of allocated memory
for which there is no remaining reference, which is what `leak' means.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]