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