ncurses 5.7 - patch 20090510
[ncurses.git] / ncurses / base / wresize.c
index a61742a57c6d00e05946919d7a0588c7f8d8e5e8..49e0d58af54c6bd610999e3a46c7a22f5802f172 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
 
 #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.30 2009/05/09 18:37:43 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;
 }
@@ -54,7 +54,9 @@ repair_subwindows(WINDOW *cmp)
     struct ldat *pline = cmp->_line;
     int row;
 
-    for (wp = _nc_windows; wp != 0; wp = wp->next) {
+    _nc_lock_global(curses);
+
+    for (each_window(SP, wp)) {
        WINDOW *tst = &(wp->win);
 
        if (tst->_parent == cmp) {
@@ -75,6 +77,7 @@ repair_subwindows(WINDOW *cmp)
            repair_subwindows(tst);
        }
     }
+    _nc_unlock_global(curses);
 }
 
 /*
@@ -92,12 +95,14 @@ wresize(WINDOW *win, int ToLines, int ToCols)
 #ifdef TRACE
     T((T_CALLED("wresize(%p,%d,%d)"), 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 +233,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);
 }