8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / ucblib / libcurses / delwin.c
blob483bb5d28ee2fbe6126462ee61b8224aed271f19
1 /*
2 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /*LINTLIBRARY*/
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)delwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
22 #endif /* not lint */
24 #include "curses.ext"
25 #include <malloc.h>
28 * This routine deletes a window and releases it back to the system.
31 int
32 delwin(WINDOW *win)
34 int i;
35 WINDOW *wp, *np;
37 if (win->_orig == NULL) {
39 * If we are the original window, delete the space for
40 * all the subwindows, and the array of space as well.
42 for (i = 0; i < win->_maxy && win->_y[i]; i++)
43 free(win->_y[i]);
44 free(win->_firstch);
45 free(win->_lastch);
46 wp = win->_nextp;
47 while (wp != win) {
48 np = wp->_nextp;
49 (void) delwin(wp);
50 wp = np;
52 } else {
54 * If we are a subwindow, take ourselves out of the
55 * list. NOTE: if we are a subwindow, the minimum list
56 * is orig followed by this subwindow, so there are
57 * always at least two windows in the list.
59 for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp)
60 continue;
61 wp->_nextp = win->_nextp;
63 free(win->_y);
64 free(win);
66 return (OK);