From 88372e14c44faddacb3c98b73dc88ce9ea492539 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 1 Sep 2025 23:36:31 -0700 Subject: Always clean up event data Finally, a use case for ‘goto’ that I think solves the issue pretty nicely. Not so evil after all, perhaps. --- xkbcat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xkbcat.c b/xkbcat.c index b7be2aa..6771003 100644 --- a/xkbcat.c +++ b/xkbcat.c @@ -140,22 +140,22 @@ int main(int argc, char *argv[]) { // or numeric keypad keys.) if (NoSymbol == s) { if (group == 0) - continue; + goto end; else { s = XkbKeycodeToKeysym(disp, ev->detail, 0 /* base group */, 0 /*shift level*/); if (NoSymbol == s) - continue; + goto end; } } if ((s >= XK_A && s <= XK_Z) || (s >= XK_a && s <= XK_z)) { - continue; + goto end; } char *str = XKeysymToString(s); if (NULL == str) - continue; + goto end; // Output line if (printKeyUps) @@ -164,6 +164,8 @@ int main(int argc, char *argv[]) { fflush(stdout); } } + + end: // Release memory associated with event data XFreeEventData(disp, cookie); } else { // No extra data to release; `event` contains everything. -- cgit v1.3-2-g0d8e