summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixXId.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-04-12 10:06:09 (GMT)
committerhobbs <hobbs>2002-04-12 10:06:09 (GMT)
commit8e510069debe72b6010098ecdac9867c534a5c6e (patch)
treedcc25f95c8ad275eff78ab29937f2130a80faa0d /unix/tkUnixXId.c
parent197b4b9a5236ad16a01f09f391f3e5a46decab27 (diff)
downloadtk-8e510069debe72b6010098ecdac9867c534a5c6e.zip
tk-8e510069debe72b6010098ecdac9867c534a5c6e.tar.gz
tk-8e510069debe72b6010098ecdac9867c534a5c6e.tar.bz2
* generic/tkInt.h:
* unix/tkUnixXId.c (TkFreeXId): frees XID resources. Made idCleanupScheduled a Tcl_TimerToken (was int) in TkDisplay structure to allow us to delete the timer scheduled for it.
Diffstat (limited to 'unix/tkUnixXId.c')
-rw-r--r--unix/tkUnixXId.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/unix/tkUnixXId.c b/unix/tkUnixXId.c
index c2be145..9f3dd82 100644
--- a/unix/tkUnixXId.c
+++ b/unix/tkUnixXId.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixXId.c,v 1.6 2001/09/25 16:25:20 dgp Exp $
+ * RCS: @(#) $Id: tkUnixXId.c,v 1.7 2002/04/12 10:06:09 hobbs Exp $
*/
/*
@@ -84,7 +84,50 @@ TkInitXId(dispPtr)
dispPtr->display->resource_alloc;
dispPtr->display->resource_alloc = AllocXId;
dispPtr->windowStackPtr = NULL;
- dispPtr->idCleanupScheduled = 0;
+ dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkFreeXId --
+ *
+ * This procedure is called to free resources for the id allocator
+ * for a given display.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Frees the id and window stack pools.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkFreeXId(dispPtr)
+ TkDisplay *dispPtr; /* Tk's information about the
+ * display. */
+{
+ TkIdStack *stackPtr, *freePtr;
+
+ if (dispPtr->idCleanupScheduled) {
+ Tcl_DeleteTimerHandler(dispPtr->idCleanupScheduled);
+ }
+
+ for (stackPtr = dispPtr->idStackPtr; stackPtr != NULL; ) {
+ freePtr = stackPtr;
+ stackPtr = stackPtr->nextPtr;
+ ckfree((char *) freePtr);
+ }
+ dispPtr->idStackPtr = NULL;
+
+ for (stackPtr = dispPtr->windowStackPtr; stackPtr != NULL; ) {
+ freePtr = stackPtr;
+ stackPtr = stackPtr->nextPtr;
+ ckfree((char *) freePtr);
+ }
+ dispPtr->windowStackPtr = NULL;
}
/*
@@ -293,8 +336,8 @@ TkFreeWindowId(dispPtr, w)
*/
if (!dispPtr->idCleanupScheduled) {
- dispPtr->idCleanupScheduled = 1;
- Tcl_CreateTimerHandler(100, WindowIdCleanup, (ClientData) dispPtr);
+ dispPtr->idCleanupScheduled =
+ Tcl_CreateTimerHandler(100, WindowIdCleanup, (ClientData) dispPtr);
}
}
@@ -328,7 +371,7 @@ WindowIdCleanup(clientData)
ClientData oldData;
static Tcl_Time timeout = {0, 0};
- dispPtr->idCleanupScheduled = 0;
+ dispPtr->idCleanupScheduled = (Tcl_TimerToken) 0;
/*
* See if it's safe to recycle the window ids. It's safe if:
@@ -375,8 +418,8 @@ WindowIdCleanup(clientData)
*/
tryAgain:
- dispPtr->idCleanupScheduled = 1;
- Tcl_CreateTimerHandler(500, WindowIdCleanup, (ClientData) dispPtr);
+ dispPtr->idCleanupScheduled =
+ Tcl_CreateTimerHandler(500, WindowIdCleanup, (ClientData) dispPtr);
}
/*