sr_dev_inst_free(): Allow NULL as argument.

This commit is contained in:
Uwe Hermann 2017-03-08 19:18:17 +01:00
parent 8662130615
commit 4bf9398802
9 changed files with 12 additions and 19 deletions

View File

@ -339,7 +339,7 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type,
/**
* Free device instance struct created by sr_dev_inst().
*
* @param sdi Device instance to free. Must not be NULL.
* @param sdi Device instance to free. If NULL, the function will do nothing.
*
* @private
*/
@ -349,6 +349,9 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
struct sr_channel_group *cg;
GSList *l;
if (!sdi)
return;
for (l = sdi->channels; l; l = l->next) {
ch = l->data;
g_free(ch->name);

View File

@ -326,7 +326,6 @@ exit_err:
if (serial)
sr_serial_dev_inst_free(serial);
g_free(devc);
if (sdi)
sr_dev_inst_free(sdi);
return NULL;

View File

@ -100,7 +100,6 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
fail:
if (hw_info)
sr_scpi_hw_info_free(hw_info);
if (sdi)
sr_dev_inst_free(sdi);
g_free(devc);

View File

@ -104,7 +104,6 @@ static struct sr_dev_inst *probe_serial_device(struct sr_scpi_dev_inst *scpi)
fail:
sr_scpi_hw_info_free(hw_info);
if (sdi)
sr_dev_inst_free(sdi);
g_free(devc);

View File

@ -488,7 +488,6 @@ exit_err:
sr_serial_dev_inst_free(serial);
}
g_free(devc);
if (sdi)
sr_dev_inst_free(sdi);
return NULL;

View File

@ -146,10 +146,7 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
fail:
if (hw_info)
sr_scpi_hw_info_free(hw_info);
if (sdi)
sr_dev_inst_free(sdi);
g_free(devc);
return NULL;
}

View File

@ -111,7 +111,6 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
fail:
if (hw_info)
sr_scpi_hw_info_free(hw_info);
if (sdi)
sr_dev_inst_free(sdi);
g_free(devc);

View File

@ -592,7 +592,6 @@ SR_API void sr_input_free(const struct sr_input *in)
if (in->module->cleanup)
in->module->cleanup((struct sr_input *)in);
if (in->sdi)
sr_dev_inst_free(in->sdi);
if (in->buf->len > 64) {
/* That seems more than just some sub-unitsize leftover... */

View File

@ -799,7 +799,6 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
scan_cleanup:
es51919_serial_clean(devc);
if (sdi)
sr_dev_inst_free(sdi);
if (serial)
sr_serial_dev_inst_free(serial);