+MODULE_ID("$Id: wresize.c,v 1.35 2011/05/21 18:55:07 tom Exp $")
+
+static int
+cleanup_lines(struct ldat *data, int length)
+{
+ while (--length >= 0)
+ free(data[length].text);
+ free(data);
+ return ERR;
+}
+
+/*
+ * If we have reallocated the ldat structs, we will have to repair pointers
+ * used in subwindows.
+ */
+static void
+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 (each_window(SP_PARM, wp)) {
+ WINDOW *tst = &(wp->win);
+
+ if (tst->_parent == cmp) {
+
+ if (tst->_pary > cmp->_maxy)
+ tst->_pary = cmp->_maxy;
+ if (tst->_parx > cmp->_maxx)
+ tst->_parx = cmp->_maxx;
+
+ if (tst->_maxy + tst->_pary > cmp->_maxy)
+ tst->_maxy = (NCURSES_SIZE_T) (cmp->_maxy - tst->_pary);
+ if (tst->_maxx + tst->_parx > cmp->_maxx)
+ tst->_maxx = (NCURSES_SIZE_T) (cmp->_maxx - tst->_parx);
+
+ for (row = 0; row <= tst->_maxy; ++row) {
+ tst->_line[row].text = &pline[tst->_pary + row].text[tst->_parx];
+ }
+ repair_subwindows(tst);
+ }
+ }
+ _nc_unlock_global(curses);
+}