summaryrefslogtreecommitdiff
path: root/lib/libcurses/lib_delwin.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-11-26 04:02:03 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-11-26 04:02:03 +0000
commitbda33b7e716d56bf1a9ecccb7e2543889f9ab1d3 (patch)
tree7bc4bcdf70ecc1d045693a309e96b304e1b49c33 /lib/libcurses/lib_delwin.c
parentcd15e61d557c4704743905eae7b88ae927cf0394 (diff)
ncurses 4.1 + changes to work with our terminfo libs (instead of
the ncurses ones). Changes are #ifdef EXTERN_TERMINFO. Post 4.1 patches will be applied in a separate commit.
Diffstat (limited to 'lib/libcurses/lib_delwin.c')
-rw-r--r--lib/libcurses/lib_delwin.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/libcurses/lib_delwin.c b/lib/libcurses/lib_delwin.c
index b3453cad74a..542abcaf437 100644
--- a/lib/libcurses/lib_delwin.c
+++ b/lib/libcurses/lib_delwin.c
@@ -26,28 +26,35 @@
**
*/
-#include "curses.priv.h"
-#include <stdlib.h>
+#include <curses.priv.h>
-int delwin(WINDOW *win)
-{
-int i;
-
- T(("delwin(%p) called", win));
+MODULE_ID("Id: lib_delwin.c,v 1.8 1997/02/01 23:22:54 tom Exp $")
- if (win == NULL)
- return(ERR);
-
- if (! (win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy && win->_line[i].text; i++)
- free(win->_line[i].text);
+static bool have_children(WINDOW *win)
+{
+ WINDOWLIST *p;
+ for (p = _nc_windows; p != 0; p = p->next) {
+ if (p->win->_flags & _SUBWIN
+ && p->win->_parent == win)
+ return TRUE;
}
+ return FALSE;
+}
+
+int delwin(WINDOW *win)
+{
+ T((T_CALLED("delwin(%p)"), win));
- free(win->_line);
+ if (win == 0
+ || have_children(win))
+ returnCode(ERR);
- touchwin((win->_flags & _SUBWIN) ? win->_parent : curscr);
+ if (win->_flags & _SUBWIN)
+ touchwin(win->_parent);
+ else if (curscr != 0)
+ touchwin(curscr);
- free(win);
+ _nc_freewin(win);
- return(OK);
+ returnCode(OK);
}