/****************************************************************************
- * Copyright (c) 1998-2006,2007 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: lib_newwin.c,v 1.41 2007/10/20 20:56:07 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.44 2008/01/13 00:28:13 tom Exp $")
static WINDOW *
remove_window_from_screen(WINDOW *win)
int i;
int result = ERR;
+ T((T_CALLED("_nc_freewin(%p)"), win));
+
if (win != 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
- if (&(p->win) == win) {
- remove_window_from_screen(win);
- if (q == 0)
- _nc_windows = p->next;
- else
- q->next = p->next;
-
- if (!(win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy; i++)
- FreeIfNeeded(win->_line[i].text);
+ if (_nc_try_global(windowlist) == 0) {
+ for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ if (&(p->win) == win) {
+ remove_window_from_screen(win);
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+
+ if (!(win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy; i++)
+ FreeIfNeeded(win->_line[i].text);
+ }
+ free(win->_line);
+ free(p);
+
+ result = OK;
+ T(("...deleted win=%p", win));
+ break;
}
- free(win->_line);
- free(p);
-
- result = OK;
- T(("...deleted win=%p", win));
- break;
}
+ _nc_unlock_global(windowlist);
}
}
- return result;
+ returnCode(result);
}
NCURSES_EXPORT(WINDOW *)
{
pthread_mutexattr_t recattr;
memset(&recattr, 0, sizeof(recattr));
- pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&(wp->mutex_use_window), &recattr);
}
#endif
returnWin(0);
}
+ _nc_lock_global(windowlist);
+
win->_curx = 0;
win->_cury = 0;
win->_maxy = num_lines - 1;
T((T_CREATE("window %p"), win));
+ _nc_unlock_global(windowlist);
returnWin(win);
}