[prog] curses forms free_field

Almut Behrens almut-behrens at gmx.net
Fri May 14 19:29:01 EST 2004


On Thu, May 13, 2004 at 04:25:46PM -0500, ed orphan wrote:
> I'm writing a small in Linux using
> curses forms for input.  When I'm
> finished with the input fields and
> try to free them, I get a segmentation error.
> This happens after the first field has
> been freed.
> eg.    unpost_form( my_form );
>         free_form( my_form);
>         for(i=0; i<MAXFIELDS; i++)
>                free_field( field[  i ] );
>     segmentation error happens here.

Basically, there doesn't seem to be anything wrong with the code, as
far as I can tell from this fragment...

Can you sucessfully compile and run the various examples (unmodified)
given in the documentation [1]? If so, it might help if you post a bit
more of your code that segfaults.  In case the author's sample code
segfaults, too, then I'd say you have a problem with incompatible
libraries. You might try building you own ncurses libs from source, or
try using valgrind [2] to find out where the real problem is.

Also, if you want, you could post your complete test code (or send it
to me off-list, depending on size) -- I'd then build it and try to run
it with the lib versions on my system. This might help to tear apart
what the problem is...

Cheers,
Almut


[1] examples available here:
http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/ncurses_programs.tar.gz

[2] valgrind is a nice debugging tool I keep recommending repeatedly
(just as I always recommend strace :) -- for details see
http://valgrind.kde.org/

 


More information about the Programming mailing list