[Top][All Lists]

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

Re: second newterm with sp_funcs enabled returns NULL pointer

From: Thomas Beierlein
Subject: Re: second newterm with sp_funcs enabled returns NULL pointer
Date: Sat, 26 Apr 2014 20:42:15 +0200

Sorry, due to server problems I have to reply from an alternative

 On Sat, Apr26, Thomas Dickey wrote:
> On Tue, Apr 22, 2014 at 07:02:46PM +0200, Thomas Beierlein wrote:  
> > Hi,
> > 
> > I am maintaining an old ncurses program for some years (tlf) which
> > uses two terminal screens. Last days I got a bug report that the
> > second screen does not work in OpenSUSE environment. A quick check
> > showed that libncurses (5.9) got build there with --enable-sp-funcs.
> > Digging a little further only a first call to newterm() returns a
> > valid SCREEN*, a second call to establish a second terminal screen
> > always returns NULL. 
> > 
> > That can also be shown by the following simple program:
> > 
> > -- 
> > #include <ncurses.h>
> > SCREEN *x;
> > SCREEN *y;
> > 
> > int main() {
> >  x = newterm(NULL, stdout, stdin);
> >  y = newterm(NULL, stdout, stdin);  
> I can reproduce this, looks like a bug (am looking into that, now).
As far as I have understood the first newterm() calls new_prescr() and
hands the allocated screen to newterm_sp. Newterm_sp() initializes the
screen and hands it back as his result to the application. As an side
effect the screen gets marked as no longer being a prescreen

The second call to newterm() checks if the current screen IsPreScreen()
which is no longer true (see above) and calls new_prescreen() again. But
as the SCREEN *sp is made static no new screen gets allocated. A
reference to the old screen - which is no longer marked as an
prescreen - is again handed over to newterm_sp(). But newterm_sp()
expects a screen which is marked as _prescreen and voila it fails.

> (as an aside, I would not expect to have two screens open for the same
> I/O - perhaps tlf doesn't do _that_)  

Works normally like a charm. Both screens gets initialized with
different sets of windows and content and gets switched back and forth
at user command with an appropriate set_term() to work with one or the
other terminal screen.



> -- 
> Thomas E. Dickey <address@hidden>
> http://invisible-island.net
> ftp://invisible-island.net  

"Do what is needful!"
Ursula LeGuin: Earthsea

reply via email to

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