std: Free channel groups from device instances as well.

This commit is contained in:
Bert Vermeulen 2014-07-24 21:01:08 +02:00
parent 07443fd204
commit 886413b6d2
1 changed files with 12 additions and 1 deletions

View File

@ -249,7 +249,8 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
{
struct drv_context *drvc;
struct sr_dev_inst *sdi;
GSList *l;
struct sr_channel_group *cg;
GSList *l, *lcg;
int ret;
if (!(drvc = driver->priv))
@ -278,9 +279,19 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
sr_scpi_free(sdi->conn);
}
if (clear_private)
/* The helper function is responsible for freeing
* its own sdi->priv! */
clear_private(sdi->priv);
else
g_free(sdi->priv);
/* Channel groups */
for (lcg = sdi->channel_groups; lcg; lcg = lcg->next) {
cg = lcg->data;
g_free(cg->name);
g_slist_free(cg->channels);
g_free(cg);
}
sr_dev_inst_free(sdi);
}