ncurses 5.7 - patch 20100116
[ncurses.git] / ncurses / base / wresize.c
index a61742a57c6d00e05946919d7a0588c7f8d8e5e8..d5ce3974e278b0cab85edd147ca2a354a8c55012 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 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            *
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 1996-2002                                      *
+ *  Author: Thomas E. Dickey 1996-on                                        *
+ *     and: Juergen Pfeifer                                                 *
  ****************************************************************************/
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: wresize.c,v 1.23 2002/09/28 15:15:51 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.32 2009/10/24 22:15:00 tom Exp $")
 
 static int
 cleanup_lines(struct ldat *data, int length)
 {
     while (--length >= 0)
-       free(data->text);
+       free(data[length].text);
     free(data);
     return ERR;
 }
@@ -53,8 +54,13 @@ repair_subwindows(WINDOW *cmp)
     WINDOWLIST *wp;
     struct ldat *pline = cmp->_line;
     int row;
+#ifdef USE_SP_WINDOWLIST
+    SCREEN *sp = _nc_screen_of(cmp);
+#endif
+
+    _nc_lock_global(curses);
 
-    for (wp = _nc_windows; wp != 0; wp = wp->next) {
+    for (each_window(SP_PARM, wp)) {
        WINDOW *tst = &(wp->win);
 
        if (tst->_parent == cmp) {
@@ -75,6 +81,7 @@ repair_subwindows(WINDOW *cmp)
            repair_subwindows(tst);
        }
     }
+    _nc_unlock_global(curses);
 }
 
 /*
@@ -90,14 +97,16 @@ wresize(WINDOW *win, int ToLines, int ToCols)
     struct ldat *new_lines = 0;
 
 #ifdef TRACE
-    T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
+    T((T_CALLED("wresize(%p,%d,%d)"), (void *) win, ToLines, ToCols));
     if (win) {
-       TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
-                         win->_begy, win->_begx,
-                         win->_maxy, win->_maxx,
-                         win->_regtop, win->_regbottom));
-       if (_nc_tracing & TRACE_UPDATE)
+       TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+                         (long) win->_begy, (long) win->_begx,
+                         (long) win->_maxy, (long) win->_maxx,
+                         (long) win->_regtop, (long) win->_regbottom));
+       if (USE_TRACEF(TRACE_UPDATE)) {
            _tracedump("...before", win);
+           _nc_unlock_global(tracef);
+       }
     }
 #endif
 
@@ -228,12 +237,14 @@ wresize(WINDOW *win, int ToLines, int ToCols)
     repair_subwindows(win);
 
 #ifdef TRACE
-    TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
-                     win->_begy, win->_begx,
-                     win->_maxy, win->_maxx,
-                     win->_regtop, win->_regbottom));
-    if (_nc_tracing & TRACE_UPDATE)
+    TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+                     (long) win->_begy, (long) win->_begx,
+                     (long) win->_maxy, (long) win->_maxx,
+                     (long) win->_regtop, (long) win->_regbottom));
+    if (USE_TRACEF(TRACE_UPDATE)) {
        _tracedump("...after:", win);
+       _nc_unlock_global(tracef);
+    }
 #endif
     returnCode(OK);
 }