diff options
| author | 2025-09-01 23:36:31 -0700 | |
|---|---|---|
| committer | 2025-09-01 23:36:31 -0700 | |
| commit | 88372e14c44faddacb3c98b73dc88ce9ea492539 (patch) | |
| tree | 5741433bd8dcf781493dad396f0b0060068168f5 | |
| parent | ca9004e5fab51f1d0a8deb7240f4136ecf76ba8a (diff) | |
| download | xkbcat-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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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. |
