X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=callback.c;h=c70dc53fb85fb06d5de6b77ac872833dbee8a22a;hb=510f49e405e71ba5c97875e7a019364e1ef5fac9;hp=e62fcd7d47245a9b431619d85b1be6e4517c56b2;hpb=75c79e318fffc6db076861856c1320fcea849bf2;p=PuTTY.git diff --git a/callback.c b/callback.c index e62fcd7d..c70dc53f 100644 --- a/callback.c +++ b/callback.c @@ -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; }