]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_freeall.c
ncurses 5.9 - patch 20120903
[ncurses.git] / ncurses / base / lib_freeall.c
index 5856dd547cd85f527f70dd4922fcb8fbd13d4b8b..38d73aa25204b96a1a3f0598814a2a4cb13dc729 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -31,7 +31,6 @@
  ****************************************************************************/
 
 #include <curses.priv.h>
-#include <term_entry.h>
 #include <tic.h>
 
 #if HAVE_NC_FREEALL
@@ -40,7 +39,7 @@
 extern int malloc_errfd;       /* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.56 2009/04/18 17:18:56 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.61 2012/08/25 19:52:47 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
@@ -66,14 +65,14 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
     if (SP_PARM != 0) {
        _nc_lock_global(curses);
 
-       while (_nc_windows != 0) {
+       while (WindowList(SP_PARM) != 0) {
            bool deleted = FALSE;
 
            /* Delete only windows that're not a parent */
-           for (each_window(p)) {
+           for (each_window(SP_PARM, p)) {
                bool found = FALSE;
 
-               for (each_window(q)) {
+               for (each_window(SP_PARM, q)) {
                    if ((p != q)
                        && (q->win._flags & _SUBWIN)
                        && (&(p->win) == q->win._parent)) {
@@ -101,7 +100,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 
     (void) _nc_printf_string(0, empty_va);
 #ifdef TRACE
-    (void) _nc_trace_buf(-1, 0);
+    (void) _nc_trace_buf(-1, (size_t) 0);
 #endif
 #if USE_WIDEC_SUPPORT
     FreeIfNeeded(_nc_wacs);
@@ -130,8 +129,9 @@ _nc_freeall(void)
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
-    char *last_setbuf = (SP_PARM != 0) ? SP_PARM->_setbuf : 0;
+    char *last_buffer = (SP_PARM != 0) ? SP_PARM->out_buffer : 0;
 
+    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
     NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG);
 #ifdef TRACE
     trace(0);                  /* close trace file, freeing its setbuf */
@@ -140,8 +140,7 @@ NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
        free(_nc_varargs("?", fake));
     }
 #endif
-    fclose(stdout);
-    FreeIfNeeded(last_setbuf);
+    FreeIfNeeded(last_buffer);
     exit(code);
 }
 
@@ -152,12 +151,12 @@ _nc_freeall(void)
 }
 
 NCURSES_EXPORT(void)
-NCURSES_SP_NAME(_nc_free_and_exit) (SCREEN *SP_PARM, int code)
+NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
     if (SP_PARM) {
        delscreen(SP_PARM);
        if (SP_PARM->_term)
-           NCURSES_SP_NAME(_nc_del_curterm) (SP_PARM, SP_PARM->_term);
+           NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx SP_PARM->_term);
     }
     exit(code);
 }