Only sr_dev_inst_free() should free channel groups.

This commit is contained in:
Bert Vermeulen 2014-11-01 13:18:09 +01:00
parent aab4b8cb70
commit 7aebe22d10
2 changed files with 5 additions and 10 deletions

View File

@ -242,7 +242,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
/** @private
* Free device instance struct created by sr_dev_inst().
* @param sdi struct* to free.
* @param sdi device instance to free.
*/
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
{
@ -260,7 +260,10 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
for (l = sdi->channel_groups; l; l = l->next) {
cg = l->data;
g_free(cg->name);
g_slist_free(cg->channels);
g_free(cg->priv);
g_free(cg);
}
g_slist_free(sdi->channel_groups);

View File

@ -249,8 +249,7 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
{
struct drv_context *drvc;
struct sr_dev_inst *sdi;
struct sr_channel_group *cg;
GSList *l, *lcg;
GSList *l;
int ret;
if (!(drvc = driver->priv))
@ -285,13 +284,6 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
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);
}