aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 07:53:24 -0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-07 11:42:46 -0300
commitd2631c3bf55ce62c16e5d6b56d2d39fe12a0db97 (patch)
treeba8f87a8c8db31ad5320b1160f0cc8ffaff2d693
parentd3ffd657670b3a9050ea53267ba5a65985449429 (diff)
main: add some g_free() in order to reduce memleak warnings
Running valgrind with gtk apps really sucks, as gtk doesn't really care about freeing stuff at the end. So, lots of leaks are reported by tools like valgrind. Let's at least free the stuff allocated at main.c at close_app() callback, in order to clean the mess a little bit. It should be noticed that gconf_client_get_string() already returns an allocated string, so no need to call g_strdup(). Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--src/main.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 1895372..9031235 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,10 +78,23 @@ static void close_app(GtkWidget* widget, cam_t *cam)
g_source_remove(cam->timeout_fps_id);
gtk_widget_destroy(widget);
+
+ g_free(cam->video_dev);
+ g_free(cam->pixdir);
+ g_free(cam->host);
+ g_free(cam->proto);
+ g_free(cam->rdir);
+ g_free(cam->rcapturefile);
+ g_free(cam->ts_string);
+ free(cam->pic_buf);
+ free(cam->tmp);
+
+ g_object_unref (G_OBJECT (cam->xml));
+ g_object_unref (G_OBJECT (cam->gc));
+
#if GTK_MAJOR_VERSION < 3
gtk_main_quit();
#endif
-
}
static cam_t cam_object = { 0 };
@@ -177,15 +190,15 @@ static void activate(GtkApplication *app)
cam->date_format = "%Y-%m-%d %H:%M:%S";
#pragma GCC diagnostic pop
- cam->pixdir = g_strdup(gconf_client_get_string(cam->gc, KEY1, NULL));
- cam->capturefile = g_strdup(gconf_client_get_string(cam->gc, KEY2, NULL));
+ cam->pixdir = gconf_client_get_string(cam->gc, KEY1, NULL);
+ cam->capturefile = gconf_client_get_string(cam->gc, KEY2, NULL);
cam->savetype = gconf_client_get_int(cam->gc, KEY3, NULL);
- cam->host = g_strdup(gconf_client_get_string(cam->gc, KEY5, NULL));
- cam->proto = g_strdup(gconf_client_get_string(cam->gc, KEY6, NULL));
- cam->rdir = g_strdup(gconf_client_get_string(cam->gc, KEY8, NULL));
- cam->rcapturefile = g_strdup(gconf_client_get_string(cam->gc, KEY9, NULL));
+ cam->host = gconf_client_get_string(cam->gc, KEY5, NULL);
+ cam->proto = gconf_client_get_string(cam->gc, KEY6, NULL);
+ cam->rdir = gconf_client_get_string(cam->gc, KEY8, NULL);
+ cam->rcapturefile = gconf_client_get_string(cam->gc, KEY9, NULL);
cam->rsavetype = gconf_client_get_int(cam->gc, KEY10, NULL);
- cam->ts_string = g_strdup(gconf_client_get_string(cam->gc, KEY16, NULL));
+ cam->ts_string = gconf_client_get_string(cam->gc, KEY16, NULL);
cam->timestamp = gconf_client_get_bool(cam->gc, KEY4, NULL);
cam->rtimestamp = gconf_client_get_bool(cam->gc, KEY11, NULL);

Privacy Policy