From: Bert Vermeulen Date: Thu, 24 Jul 2014 19:01:39 +0000 (+0200) Subject: demo: Free analog channel groups when done with them. X-Git-Tag: libsigrok-0.4.0~1207 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ed0b7fed106881941faa4d9b3f1bfdc17295d58d;p=libsigrok.git demo: Free analog channel groups when done with them. This fixes a memory leak. --- diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index a81217d7..11e157ec 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -379,9 +379,25 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } +static void clear_helper(void *priv) +{ + struct dev_context *devc; + struct sr_channel_group *cg; + GSList *l; + + devc = priv; + for (l = devc->analog_channel_groups; l; l = l->next) { + cg = l->data; + /* Analog generators. */ + g_free(cg->priv); + } + g_slist_free(devc->analog_channel_groups); + g_free(devc); +} + static int cleanup(void) { - return std_dev_clear(di, NULL); + return std_dev_clear(di, clear_helper); } static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,