Commit | Line | Data |
---|---|---|
d51d9cc8 KA |
1 | # include "curses.ext" |
2 | ||
3 | /* | |
4 | * This routine deletes a window and releases it back to the system. | |
5 | * | |
52bf106d | 6 | * %G% (Berkeley) @(#)delwin.c 1.5 |
d51d9cc8 KA |
7 | */ |
8 | delwin(win) | |
9 | reg WINDOW *win; { | |
10 | ||
c1ba161f KA |
11 | reg int i; |
12 | reg WINDOW *wp, *np; | |
d51d9cc8 | 13 | |
c1ba161f | 14 | if (win->_orig == NULL) { |
52bf106d KA |
15 | /* |
16 | * If we are the original window, delete the space for | |
17 | * all the subwindows, and the array of space as well. | |
18 | */ | |
d51d9cc8 KA |
19 | for (i = 0; i < win->_maxy && win->_y[i]; i++) |
20 | cfree(win->_y[i]); | |
c1ba161f KA |
21 | wp = win->_nextp; |
22 | while (wp != win) { | |
23 | np = wp->_nextp; | |
24 | delwin(wp); | |
25 | wp = np; | |
26 | } | |
27 | } | |
52bf106d KA |
28 | else { |
29 | /* | |
30 | * If we are a subwindow, take ourself out of the | |
31 | * list. NOTE: if we are a subwindow, the minimum list | |
32 | * is orig followed by this subwindow, so there are | |
33 | * always at least two windows in the list. | |
34 | */ | |
35 | for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) | |
36 | continue; | |
37 | wp->_nextp = win->_nextp; | |
38 | } | |
d51d9cc8 | 39 | cfree(win->_y); |
1fe7814b KA |
40 | cfree(win->_firstch); |
41 | cfree(win->_lastch); | |
d51d9cc8 KA |
42 | cfree(win); |
43 | } |