From 489e2955687bccb263e1ece3a1615b3356c990f2 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 13 Dec 2011 16:27:18 +0100 Subject: Fix some leaks --- configure.ac | 2 +- src/config.c | 4 ++++ src/interface.c | 10 +++++++++- src/pa-sink-ctl.c | 30 +++++++++++++++++++++++++----- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 207f9d7..81eb2c8 100644 --- a/configure.ac +++ b/configure.ac @@ -36,7 +36,7 @@ PKG_CHECK_MODULES(PULSE_MAINLOOP, [libpulse-mainloop-glib], [], AC_MSG_ERROR([li PKG_CHECK_MODULES(GLIB, [glib-2.0], [], AC_MSG_ERROR([glib required])) if test "x$GCC" = "xyes"; then - GCC_CFLAGS="-Wall -Werror -pedantic -std=c99 -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden" + GCC_CFLAGS="-Wall -pedantic -std=c99 -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden" fi AC_SUBST(GCC_CFLAGS) diff --git a/src/config.c b/src/config.c index a3535d1..96fba47 100644 --- a/src/config.c +++ b/src/config.c @@ -56,6 +56,7 @@ parse_priorities(struct config *cfg) list_append_struct(cfg->priorities, p); } + g_strfreev(groups); return 0; @@ -68,6 +69,8 @@ error: g_printerr("Failed to read property in prioritiy group '%s': %s\n", groups[i], error->message); + g_strfreev(groups); + return -1; } @@ -144,6 +147,7 @@ read_input_mappings(struct config *cfg) g_hash_table_insert(cfg->keymap, GINT_TO_POINTER(key), &command_cbs[i]); } + g_strfreev(list); } return 0; diff --git a/src/interface.c b/src/interface.c index a744cfd..9cc31f8 100644 --- a/src/interface.c +++ b/src/interface.c @@ -198,10 +198,17 @@ interface_clear(struct context *ctx) { g_source_remove(ctx->resize_source_id); g_source_remove(ctx->input_source_id); +#ifdef HAVE_SIGNALFD close(ctx->signal_fd); +#endif clear(); refresh(); + delwin(ctx->menu_win); + delwin(ctx->msg_win); endwin(); + delscreen(NULL); + if (ctx->status) + g_free(ctx->status); } void @@ -278,7 +285,8 @@ interface_init(struct context *ctx) exit(EXIT_FAILURE); ctx->signal_fd = signalfd(-1, &mask, 0); channel = g_io_channel_unix_new(ctx->signal_fd); - g_io_add_watch(channel, G_IO_IN, resize_gio, ctx); + ctx->resize_source_id = + g_io_add_watch(channel, G_IO_IN, resize_gio, ctx); g_io_channel_unref(channel); } #else diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c index b4e3ef4..c3ea04e 100644 --- a/src/pa-sink-ctl.c +++ b/src/pa-sink-ctl.c @@ -173,6 +173,24 @@ sink_info_cb(pa_context *c, const pa_sink_info *i, compare_sink_priority); } +static void +sink_free(gpointer data) +{ + struct sink_info *sink = data; + + g_free(sink->name); + g_free(sink); +} + +static void +sink_input_free(gpointer data) +{ + struct sink_input_info *input = data; + + g_free(input->name); + g_free(input); +} + static void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, guint32 idx, gpointer userdata) @@ -204,13 +222,13 @@ subscribe_cb(pa_context *c, pa_subscription_event_type_t t, case PA_SUBSCRIPTION_EVENT_SINK: object = find_sink_by_idx(ctx, idx); ctx->sink_list = g_list_remove(ctx->sink_list, object); - g_free(object); + sink_free(object); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: object = find_sink_input_by_idx(ctx, idx); ctx->input_list = g_list_remove(ctx->input_list, object); - g_free(object); + sink_input_free(object); break; default: return; @@ -339,14 +357,16 @@ main(int argc, char** argv) g_main_loop_run(ctx->loop); interface_clear(ctx); - g_list_free_full(ctx->sink_list, g_free); - g_list_free_full(ctx->input_list, g_free); + g_list_free_full(ctx->sink_list, sink_free); + g_list_free_full(ctx->input_list, sink_input_free); pa_glib_mainloop_free(m); + pa_context_unref(ctx->context); g_main_loop_unref(ctx->loop); config_uninit(&ctx->config); + g_free(ctx); + return 0; } - -- cgit