Commit | Line | Data |
---|---|---|
6e1c93d0 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
c07973a2 | 5 | * %sccs.include.redist.c% |
6e1c93d0 DF |
6 | */ |
7 | ||
8 | #ifndef lint | |
c07973a2 | 9 | static char sccsid[] = "@(#)delwin.c 5.4 (Berkeley) %G%"; |
2f14f200 | 10 | #endif /* not lint */ |
6e1c93d0 | 11 | |
d51d9cc8 KA |
12 | # include "curses.ext" |
13 | ||
14 | /* | |
15 | * This routine deletes a window and releases it back to the system. | |
16 | * | |
d51d9cc8 KA |
17 | */ |
18 | delwin(win) | |
19 | reg WINDOW *win; { | |
20 | ||
c1ba161f KA |
21 | reg int i; |
22 | reg WINDOW *wp, *np; | |
d51d9cc8 | 23 | |
c1ba161f | 24 | if (win->_orig == NULL) { |
52bf106d KA |
25 | /* |
26 | * If we are the original window, delete the space for | |
27 | * all the subwindows, and the array of space as well. | |
28 | */ | |
d51d9cc8 | 29 | for (i = 0; i < win->_maxy && win->_y[i]; i++) |
d45d8bdb JB |
30 | free(win->_y[i]); |
31 | free(win->_firstch); | |
32 | free(win->_lastch); | |
c1ba161f KA |
33 | wp = win->_nextp; |
34 | while (wp != win) { | |
35 | np = wp->_nextp; | |
36 | delwin(wp); | |
37 | wp = np; | |
38 | } | |
39 | } | |
52bf106d KA |
40 | else { |
41 | /* | |
d45d8bdb | 42 | * If we are a subwindow, take ourselves out of the |
52bf106d KA |
43 | * list. NOTE: if we are a subwindow, the minimum list |
44 | * is orig followed by this subwindow, so there are | |
45 | * always at least two windows in the list. | |
46 | */ | |
47 | for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) | |
48 | continue; | |
49 | wp->_nextp = win->_nextp; | |
50 | } | |
d45d8bdb JB |
51 | free(win->_y); |
52 | free(win); | |
d51d9cc8 | 53 | } |