]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - callback.c
first pass
[PuTTY.git] / callback.c
index e62fcd7d47245a9b431619d85b1be6e4517c56b2..c70dc53fb85fb06d5de6b77ac872833dbee8a22a 100644 (file)
@@ -50,19 +50,25 @@ void queue_toplevel_callback(toplevel_callback_fn_t fn, void *ctx)
 
 void run_toplevel_callbacks(void)
 {
-    while (cbhead) {
+    if (cbhead) {
         struct callback *cb = cbhead;
         /*
          * Careful ordering here. We call the function _before_
          * advancing cbhead (though, of course, we must free cb
          * _after_ advancing it). This means that if the very last
          * callback schedules another callback, cbhead does not become
-         * NULL at any point in this while loop, and so the frontend
-         * notification function won't be needlessly pestered.
+         * NULL at any point, and so the frontend notification
+         * function won't be needlessly pestered.
          */
         cb->fn(cb->ctx);
         cbhead = cb->next;
         sfree(cb);
+        if (!cbhead)
+            cbtail = NULL;
     }
-    cbtail = NULL;
+}
+
+int toplevel_callback_pending(void)
+{
+    return cbhead != NULL;
 }