]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_freeall.c
ncurses 5.7 - patch 20100717
[ncurses.git] / ncurses / base / lib_freeall.c
index e3625a2ffe2a414e3fd7786ec6e40eb8529d299e..5bcc974bc2577d27a03990e29273c4467823fa1f 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
  *                                                                          *
  * 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 <curses.priv.h>
-#include <term_entry.h>
 #include <tic.h>
 
 #if HAVE_NC_FREEALL
 #include <tic.h>
 
 #if HAVE_NC_FREEALL
 extern int malloc_errfd;       /* FIXME */
 #endif
 
 extern int malloc_errfd;       /* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.53 2008/09/20 18:28:51 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.59 2010/01/23 17:57:43 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
  * use for it as an extension).
  */
 NCURSES_EXPORT(void)
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
  * use for it as an extension).
  */
 NCURSES_EXPORT(void)
-_nc_freeall(void)
+NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
 {
     WINDOWLIST *p, *q;
     static va_list empty_va;
 
     T((T_CALLED("_nc_freeall()")));
 #if NO_LEAKS
 {
     WINDOWLIST *p, *q;
     static va_list empty_va;
 
     T((T_CALLED("_nc_freeall()")));
 #if NO_LEAKS
-    if (SP != 0) {
-       if (SP->_oldnum_list != 0) {
-           FreeAndNull(SP->_oldnum_list);
+    if (SP_PARM != 0) {
+       if (SP_PARM->_oldnum_list != 0) {
+           FreeAndNull(SP_PARM->_oldnum_list);
        }
        }
-       if (SP->_panelHook.destroy != 0) {
-           SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+       if (SP_PARM->_panelHook.destroy != 0) {
+           SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
        }
     }
 #endif
        }
     }
 #endif
-    if (SP != 0) {
+    if (SP_PARM != 0) {
        _nc_lock_global(curses);
 
        _nc_lock_global(curses);
 
-       while (_nc_windows != 0) {
+       while (WindowList(SP_PARM) != 0) {
            bool deleted = FALSE;
 
            /* Delete only windows that're not a parent */
            bool deleted = FALSE;
 
            /* Delete only windows that're not a parent */
-           for (each_window(p)) {
+           for (each_window(SP_PARM, p)) {
                bool found = FALSE;
 
                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)) {
                    if ((p != q)
                        && (q->win._flags & _SUBWIN)
                        && (&(p->win) == q->win._parent)) {
@@ -95,17 +94,17 @@ _nc_freeall(void)
            if (!deleted)
                break;
        }
            if (!deleted)
                break;
        }
-       delscreen(SP);
+       delscreen(SP_PARM);
        _nc_unlock_global(curses);
     }
        _nc_unlock_global(curses);
     }
-    if (cur_term != 0)
-       del_curterm(cur_term);
 
     (void) _nc_printf_string(0, empty_va);
 #ifdef TRACE
     (void) _nc_trace_buf(-1, 0);
 #endif
 
     (void) _nc_printf_string(0, empty_va);
 #ifdef TRACE
     (void) _nc_trace_buf(-1, 0);
 #endif
-
+#if USE_WIDEC_SUPPORT
+    FreeIfNeeded(_nc_wacs);
+#endif
     _nc_leaks_tinfo();
 
 #if HAVE_LIBDBMALLOC
     _nc_leaks_tinfo();
 
 #if HAVE_LIBDBMALLOC
@@ -119,12 +118,20 @@ _nc_freeall(void)
     returnVoid;
 }
 
     returnVoid;
 }
 
+#if NCURSES_SP_FUNCS
 NCURSES_EXPORT(void)
 NCURSES_EXPORT(void)
-_nc_free_and_exit(int code)
+_nc_freeall(void)
+{
+    NCURSES_SP_NAME(_nc_freeall) (CURRENT_SCREEN);
+}
+#endif
+
+NCURSES_EXPORT(void)
+NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
 {
-    char *last_setbuf = (SP != 0) ? SP->_setbuf : 0;
+    char *last_setbuf = (SP_PARM != 0) ? SP_PARM->_setbuf : 0;
 
 
-    _nc_freeall();
+    NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG);
 #ifdef TRACE
     trace(0);                  /* close trace file, freeing its setbuf */
     {
 #ifdef TRACE
     trace(0);                  /* close trace file, freeing its setbuf */
     {
@@ -144,12 +151,21 @@ _nc_freeall(void)
 }
 
 NCURSES_EXPORT(void)
 }
 
 NCURSES_EXPORT(void)
-_nc_free_and_exit(int code)
+NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code)
 {
 {
-    if (SP)
-       delscreen(SP);
-    if (cur_term != 0)
-       del_curterm(cur_term);
+    if (SP_PARM) {
+       delscreen(SP_PARM);
+       if (SP_PARM->_term)
+           NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx SP_PARM->_term);
+    }
     exit(code);
 }
 #endif
     exit(code);
 }
 #endif
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_free_and_exit(int code)
+{
+    NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code);
+}
+#endif