1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)delwin.c 5.4 (Berkeley) 06/01/90"; 10 #endif /* not lint */ 11 12 # include "curses.ext" 13 14 /* 15 * This routine deletes a window and releases it back to the system. 16 * 17 */ 18 delwin(win) 19 reg WINDOW *win; { 20 21 reg int i; 22 reg WINDOW *wp, *np; 23 24 if (win->_orig == NULL) { 25 /* 26 * If we are the original window, delete the space for 27 * all the subwindows, and the array of space as well. 28 */ 29 for (i = 0; i < win->_maxy && win->_y[i]; i++) 30 free(win->_y[i]); 31 free(win->_firstch); 32 free(win->_lastch); 33 wp = win->_nextp; 34 while (wp != win) { 35 np = wp->_nextp; 36 delwin(wp); 37 wp = np; 38 } 39 } 40 else { 41 /* 42 * If we are a subwindow, take ourselves out of the 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 } 51 free(win->_y); 52 free(win); 53 } 54