ncurses 6.2 - patch 20200502
[ncurses.git] / ncurses / base / use_window.c
index 4c9b1375f288b839b7a65186948c92c01f5ab828..4893053bd1554ec74e27d8541cf4a2c0d7ca4799 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2008 Free Software Foundation, Inc.                   *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2007-2009,2016 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: use_window.c,v 1.3 2008/01/13 00:36:22 tom Exp $")
-
-#ifdef USE_PTHREADS
-NCURSES_EXPORT(void)
-_nc_lock_window(WINDOW *win)
-{
-    WINDOWLIST *p;
-
-    _nc_lock_global(windowlist);
-    for (p = _nc_windows; p != 0; p = p->next) {
-       if (&(p->win) == win) {
-           _nc_mutex_lock(&(p->mutex_use_window));
-           break;
-       }
-    }
-    _nc_unlock_global(windowlist);
-}
-
-NCURSES_EXPORT(void)
-_nc_unlock_window(WINDOW *win)
-{
-    WINDOWLIST *p;
-
-    _nc_lock_global(windowlist);
-    for (p = _nc_windows; p != 0; p = p->next) {
-       if (&(p->win) == win) {
-           _nc_mutex_unlock(&(p->mutex_use_window));
-           break;
-       }
-    }
-    _nc_unlock_global(windowlist);
-}
-#endif
+MODULE_ID("$Id: use_window.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
-use_window(WINDOW *win, NCURSES_CALLBACK func, void *data)
+use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
 {
     int code = OK;
+    TR_FUNC_BFR(1);
+
+    T((T_CALLED("use_window(%p,%s,%p)"),
+       (void *) win,
+       TR_FUNC_ARG(0, func),
+       data));
 
-    T((T_CALLED("use_window(%p,%p,%p)"), win, func, data));
-    _nc_lock_window(win);
+    _nc_lock_global(curses);
     code = func(win, data);
-    _nc_unlock_window(win);
+    _nc_unlock_global(curses);
 
     returnCode(code);
 }