[Sussex] ncurses is conspiring against me.
Captain Redbeard
hairy.one at virgin.net
Sat May 14 14:24:10 UTC 2005
Hi again,
I think I've finally gotten my head around this dynamic
memory allocation thing. I've had to re-design the program
from scratch having found some MAJOR design flaws but now
I've gotten it up to the point that it contains most of the
original data structures and sub-routines with Valgrind
reporting zero errors and zero memory leaks. However,
having to that point and being ready to re-code the
functionality, I've hit a new problem with the ncurses
library that I would to get handled.
Take the following program, it does nothing at all except
initialise and clean-up the ncurses library and exits:
#include <ncurses.h>
int main()
{
initscr();
endwin();
return 0;
}
Not very exciting, not very useful. However, despite its
small size, it seems to contain a bug anyway! The code was
compiled with the command "gcc -Wall -o ncurses ncurses.c
-lncurses" and compiled and ran fine, however when I checked
the program with Valgrind I got the following output:
.
.
.
==22833== malloc/free: in use at exit: 82904 bytes in 162
blocks.
==22833== malloc/free: 164 allocs, 2 frees, 82926 bytes
allocated.
.
.
.
I've looked at whatever info I could find about ncurses,
which wasn't a lot, but I don't see any other functions I
need to call to avoid this memory leak from occurring. My
question really is is this leak (A) occurring because there
is some routine I meant to call but haven't, (B) a bug in
ncurses itself or (C) a fact of life that I don't need to
worry about and can disregard?
I would like to be able to fix it so that Valgrind reports
no unfreed memory as my current philosophy of keeping
Valgrind happy has been very successful. Also, I don't know
how I would tell if any leaks reported by Valgrind are
occurring because of ncurses calls or because of something
I've done so this situation could potentially obscure some
genuine bugs on my part. Any ideas?
--
Captain Redbeard
======================================================
Insomnia - it's not a condition, it's a mentality.
Registered Linux user: 388693.
Registered Linux machines: 289172, 289173.
v2sw5+8C+JGhw5ln4/5pr6/7Ock1ma6/8l6+8Sw3+2e4t2b9Hen4+6
g5+3RHaIr9 Hackerkey.com
======================================================
More information about the Sussex
mailing list