]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_newwin.c
ncurses 6.0 - patch 20170325
[ncurses.git] / ncurses / base / lib_newwin.c
index a6c64beaaf4a1c0efc45fde3cb30164e8c9a4568..262454eb180dfb242d7dbba741b0f0716e06c61f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -43,7 +43,7 @@
 #include <curses.priv.h>
 #include <stddef.h>
 
-MODULE_ID("$Id: lib_newwin.c,v 1.71 2011/05/28 21:32:51 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.73 2017/03/25 23:33:03 tom Exp $")
 
 #define window_is(name) ((sp)->_##name == win)
 
@@ -91,8 +91,6 @@ remove_window_from_screen(WINDOW *win)
 NCURSES_EXPORT(int)
 _nc_freewin(WINDOW *win)
 {
-    WINDOWLIST *p, *q;
-    int i;
     int result = ERR;
 #ifdef USE_SP_WINDOWLIST
     SCREEN *sp = _nc_screen_of(win);   /* pretend this is parameter */
@@ -101,17 +99,23 @@ _nc_freewin(WINDOW *win)
     T((T_CALLED("_nc_freewin(%p)"), (void *) win));
 
     if (win != 0) {
+
        if (_nc_nonsp_try_global(curses) == 0) {
+           WINDOWLIST *p, *q;
+
            q = 0;
-           for (each_window(SP_PARM, p)) {
+           for (each_window(sp, p)) {
+
                if (&(p->win) == win) {
                    remove_window_from_screen(win);
                    if (q == 0)
-                       WindowList(SP_PARM) = p->next;
+                       WindowList(sp) = p->next;
                    else
                        q->next = p->next;
 
                    if (!(win->_flags & _SUBWIN)) {
+                       int i;
+
                        for (i = 0; i <= win->_maxy; i++)
                            FreeIfNeeded(win->_line[i].text);
                    }