[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Valgrind reports possibly lost memory
From: |
Thomas Dickey |
Subject: |
Re: Valgrind reports possibly lost memory |
Date: |
Mon, 30 May 2022 19:10:28 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Mon, May 30, 2022 at 03:24:43PM -0400, Steve Litt wrote:
> Thomas Dickey said on Mon, 30 May 2022 06:01:04 -0400
>
> >On Mon, May 30, 2022 at 10:22:21AM +0200, TheJackiMonster wrote:
>
> >>
> >> Surprisingly running vim on my system which should use the same
> >> ncurses doesn't report any leakage at all.
> >
> >vim uses the termcap interface (no initscr/endwin).
>
> Is there documentation anywhere telling how to use the termcap
> interface and what its benefits and problems are?
man tgetent
DESCRIPTION
These routines are included as a conversion aid for programs that use
the termcap library. Their parameters are the same and the routines
are emulated using the terminfo database. Thus, they can only be used
to query the capabilities of entries for which a terminfo entry has
been compiled.
(writing tutorials is different from documenting things)
> >
> >Last year, there was some discussion about leaks in that,
> >after which perhaps Bram took my advice to use del_curterm().
fwiw, it started here:
https://invisible-island.net/ncurses/NEWS.html#index-t20210821
referring to the section of terminfo(5) beginning here:
https://invisible-island.net/ncurses/man/terminfo.5.html#h3-Parameterized-Strings
The terms "static" and "dynamic" are misleading. Historically,
these are simply two different sets of variables, whose values are
not reset between calls to tparm(3x). However, that fact is not
documented in other implementations. Relying on it will adversely
impact portability to other implementations:
which involved allocating memory for each "SCREEN" to manage the variables.
> Is there documentation of how to use del_curterm in order to remove
> memory leak artifacts from ncurses?
Not exactly. I explained to Bram that the termcap interface as such
doesn't provide a way to free memory, but that because it is on top
of terminfo, that calling del_curterm would be as good as he'd get
without using the debugging library.
Unlike the "SCREEN*", the terminfo interface has a convenient global variable:
TERMINAL *cur_term;
though knowing what it's good for isn't necessarily crystal clear:
The del_curterm routine frees the space pointed to by oterm and makes
it available for further use. If oterm is the same as cur_term, refer‐
ences to any of the terminfo boolean, numeric, and string variables
thereafter may refer to invalid memory locations until another se‐
tupterm has been called.
The exit_curses/exit_terminfo manpage doesn't mention delscreen and
del_curterm...
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: PGP signature