summaryrefslogtreecommitdiff
path: root/plugins/hotkeys
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-12 22:48:50 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-12 22:48:50 +0100
commiteb09fe0fbb0a4ac90527e0234c9481033bd66abd (patch)
tree827cc728a7e08bc15e932b0eeb8c0b348128fb85 /plugins/hotkeys
parent4adbda3bfc21c32f8447eae3a70b545791bb958f (diff)
fixed memleak in hotkeys plugin
Diffstat (limited to 'plugins/hotkeys')
-rw-r--r--plugins/hotkeys/hotkeys.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c
index ae186254..622fc5fb 100644
--- a/plugins/hotkeys/hotkeys.c
+++ b/plugins/hotkeys/hotkeys.c
@@ -61,21 +61,9 @@ typedef struct {
} known_command_t;
static int
-get_keycode (Display *disp, const char* name) {
- static int first_kk, last_kk;
- static KeySym* syms;
- static int ks_per_kk;
- static int first_time = 1;
+get_keycode (Display *disp, const char* name, KeySym *syms, int first_kk, int last_kk, int ks_per_kk) {
int i, ks;
- if (first_time)
- {
- XDisplayKeycodes (disp, &first_kk, &last_kk);
-
- syms = XGetKeyboardMapping (disp, first_kk, last_kk - first_kk, &ks_per_kk);
- first_time = 0;
- }
-
for (i = 0; i < last_kk-first_kk; i++)
{
KeySym sym = * (syms + i*ks_per_kk);
@@ -171,6 +159,13 @@ get_command (const char* command)
static int
read_config (Display *disp)
{
+ int ks_per_kk;
+ int first_kk, last_kk;
+ KeySym* syms;
+
+ XDisplayKeycodes (disp, &first_kk, &last_kk);
+ syms = XGetKeyboardMapping (disp, first_kk, last_kk - first_kk, &ks_per_kk);
+
DB_conf_item_t *item = deadbeef->conf_find ("hotkeys.", NULL);
while (item) {
// fprintf (stderr, "hotkeys: adding %s %s\n", item->key, item->value);
@@ -233,7 +228,7 @@ read_config (Display *disp)
}
else {
// lookup name table
- cmd_entry->keycode = get_keycode (disp, p);
+ cmd_entry->keycode = get_keycode (disp, p, syms, first_kk, last_kk, ks_per_kk);
}
if (!cmd_entry->keycode)
{
@@ -261,6 +256,7 @@ read_config (Display *disp)
}
item = deadbeef->conf_find ("hotkeys.", item);
}
+ XFree (syms);
}
DB_plugin_t *