summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-09-01 23:36:31 -0700
committerGravatar Tom Willemse2025-09-01 23:36:31 -0700
commit88372e14c44faddacb3c98b73dc88ce9ea492539 (patch)
tree5741433bd8dcf781493dad396f0b0060068168f5
parentca9004e5fab51f1d0a8deb7240f4136ecf76ba8a (diff)
downloadxkbcat-88372e14c44faddacb3c98b73dc88ce9ea492539.tar.gz
xkbcat-88372e14c44faddacb3c98b73dc88ce9ea492539.zip
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.
-rw-r--r--xkbcat.c10
1 files 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.