diff options
author | edman007 <edman007@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2009-11-17 04:01:50 +0000 |
---|---|---|
committer | edman007 <edman007@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2009-11-17 04:01:50 +0000 |
commit | 6ae9438738d02ceb411c90b05e7f5860e57d183e (patch) | |
tree | cc310875c54dc2445a6a29ab13393d5dc595d19e | |
parent | ca7f4df6326b76895780ec17a590862b4806d4f5 (diff) | |
download | lcd4linux-6ae9438738d02ceb411c90b05e7f5860e57d183e.tar.gz |
Fixed a few more leaks,
Valgrind no longers reports any leaks in plugin_dbus.c
(though there are still a few in the dbus libs)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1058 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r-- | plugin_dbus.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/plugin_dbus.c b/plugin_dbus.c index af5cfc1..a7b623e 100644 --- a/plugin_dbus.c +++ b/plugin_dbus.c @@ -143,6 +143,7 @@ static void free_args(int argc, char **argv); static int lcd_dbus_init(void); static void handle_inbound_signal(void *signal, int argc, char **argv); +static void free_handle_signal(handle_signal_t * sig); //given a signal, will add a hook so when the signal appears your callback is called static lcd_sig_t *lcd_register_signal(const char *sender, const char *path, @@ -178,11 +179,17 @@ static int clear_signal_txt(const int sig) if (s == NULL) { return 1; } - s->argc = 0; + int i; if (s->arguments != NULL) { + for (i = 0; i < s->argc; i++) { + if (s->arguments[i] != NULL) { + free(s->arguments[i]); + } + } free(s->arguments); s->arguments = NULL; } + s->argc = 0; return 0; } @@ -309,17 +316,26 @@ static void load_dbus_cfg(void) sig_info->event_name = strdup(eventname); } - if (!lcd_register_signal(sender, path, interface, member, handle_inbound_signal, sig_info, free)) { + if (!lcd_register_signal(sender, path, interface, member, handle_inbound_signal, + sig_info, (void (*)(void *)) free_handle_signal)) { error("[DBus] Error Registering signal %d", i); } + cleanup: + free(sender); + free(path); + free(interface); + free(member); + free(eventname); + } +} + +static void free_handle_signal(handle_signal_t * sig) +{ + if (sig->event_name != NULL) { + free(sig->event_name); } - cleanup: - free(sender); - free(path); - free(interface); - free(member); - free(eventname); + free(sig); } /* plugin initialization */ |