sr_dev_inst_free() takes care of that.
return SR_ERR_BUG;
}
- g_free(sdi->priv);
sr_dev_inst_free(sdi);
return SR_OK;
ret = SR_ERR_BUG;
continue;
}
- g_free(sdi->priv);
sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);
ret = SR_ERR_BUG;
continue;
}
-#if 0
- /*
- * Fixes a segfault as it's free()d elsewhere already.
- * TODO: Document who is supposed to free this, and when.
- */
- if (sdi->priv != NULL)
- g_free(sdi->priv);
- else
- sr_err("la8: %s: sdi->priv was NULL, nothing "
- "to do", __func__);
-#endif
sr_dev_inst_free(sdi); /* Returns void. */
}
g_slist_free(device_instances); /* Returns void. */
{
GSList *l;
struct sr_device_instance *sdi;
- int ret = SR_OK;
+ int ret;
+ ret = SR_OK;
/* Properly close all devices. */
for (l = device_instances; l; l = l->next) {
if (!(sdi = l->data)) {
}
if (sdi->serial->fd != -1)
serial_close(sdi->serial->fd);
- g_free(sdi->priv);
- sdi->priv = NULL;
sr_dev_inst_free(sdi);
}
g_slist_free(device_instances);
device_instances = NULL;
- return SR_OK;
+ return ret;
}
static int hw_opendev(int device_index)
static int hw_cleanup(void)
{
GSList *l;
+ struct sr_device_instance *sdi;
- /* TODO: Error handling. */
-
- /* Properly close all devices... */
- for (l = device_instances; l; l = l->next)
- close_device((struct sr_device_instance *)l->data);
-
- /* ...and free all their memory. */
- for (l = device_instances; l; l = l->next)
- g_free(l->data);
+ for (l = device_instances; l; l = l->next) {
+ sdi = l->data;
+ /* Properly close all devices... */
+ close_device(sdi);
+ /* ...and free all their memory. */
+ sr_dev_inst_free(sdi);
+ }
g_slist_free(device_instances);
device_instances = NULL;
{
GSList *l;
- /* TODO: Error handling. */
-
for (l = device_instances; l; l = l->next)
sr_dev_inst_free(l->data);
-
g_slist_free(device_instances);
device_instances = NULL;