aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/base/lib_newwin.c
diff options
context:
space:
mode:
authorRong-En Fan <rafan@FreeBSD.org>2008-05-09 02:28:12 +0000
committerRong-En Fan <rafan@FreeBSD.org>2008-05-09 02:28:12 +0000
commitaa59d4d4c5dda7e1c6f9dc0cc6edc58992a525c7 (patch)
tree502fa0a691368fb8b60b62eef10b3f3332efe830 /contrib/ncurses/ncurses/base/lib_newwin.c
parentd8977eaf361f5fdc1261c3f3524988f661ed926e (diff)
downloadsrc-aa59d4d4c5dda7e1c6f9dc0cc6edc58992a525c7.tar.gz
src-aa59d4d4c5dda7e1c6f9dc0cc6edc58992a525c7.zip
Import ncurses 5.6-20080503 snapshot onto the vender branchvendor/ncurses/5.6-20080503
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=178866 svn path=/vendor/ncurses/5.6-20080503/; revision=178868; tag=vendor/ncurses/5.6-20080503
Diffstat (limited to 'contrib/ncurses/ncurses/base/lib_newwin.c')
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c70
1 files changed, 31 insertions, 39 deletions
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index 21ba95f34ed6..7f7aa3e04f1e 100644
--- a/contrib/ncurses/ncurses/base/lib_newwin.c
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -40,42 +40,39 @@
*/
#include <curses.priv.h>
+#include <stddef.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.44 2008/01/13 00:28:13 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.50 2008/05/03 16:36:39 tom Exp $")
-static WINDOW *
+#define window_is(name) ((sp)->_##name == win)
+
+#if USE_REENTRANT
+#define remove_window(name) \
+ sp->_##name = 0
+#else
+#define remove_window(name) \
+ sp->_##name = 0; \
+ if (win == name) \
+ name = 0
+#endif
+
+static void
remove_window_from_screen(WINDOW *win)
{
- SCREEN **scan = &_nc_screen_chain;
-
- while (*scan) {
- SCREEN *sp = *scan;
- if (sp->_curscr == win) {
- sp->_curscr = 0;
-#if !USE_REENTRANT
- if (win == curscr)
- curscr = 0;
-#endif
- } else if (sp->_stdscr == win) {
- sp->_stdscr = 0;
-#if !USE_REENTRANT
- if (win == stdscr)
- stdscr = 0;
-#endif
- } else if (sp->_newscr == win) {
- sp->_newscr = 0;
-#if !USE_REENTRANT
- if (win == newscr)
- newscr = 0;
-#endif
- } else {
- scan = &(*scan)->_next_screen;
- continue;
+ SCREEN *sp;
+
+ for (each_screen(sp)) {
+ if (window_is(curscr)) {
+ remove_window(curscr);
+ break;
+ } else if (window_is(stdscr)) {
+ remove_window(stdscr);
+ break;
+ } else if (window_is(newscr)) {
+ remove_window(newscr);
+ break;
}
- break;
}
-
- return 0;
}
NCURSES_EXPORT(int)
@@ -89,7 +86,8 @@ _nc_freewin(WINDOW *win)
if (win != 0) {
if (_nc_try_global(windowlist) == 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ q = 0;
+ for (each_window(p)) {
if (&(p->win) == win) {
remove_window_from_screen(win);
if (q == 0)
@@ -108,6 +106,7 @@ _nc_freewin(WINDOW *win)
T(("...deleted win=%p", win));
break;
}
+ q = p;
}
_nc_unlock_global(windowlist);
}
@@ -230,14 +229,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
returnWin(0);
-#ifdef USE_PTHREADS
- {
- pthread_mutexattr_t recattr;
- memset(&recattr, 0, sizeof(recattr));
- pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL);
- pthread_mutex_init(&(wp->mutex_use_window), &recattr);
- }
-#endif
+ _nc_mutex_init(&(wp->mutex_use_window));
win = &(wp->win);