sr_dev_inst_free(): Allow NULL as argument.
This commit is contained in:
parent
8662130615
commit
4bf9398802
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -488,7 +488,6 @@ exit_err:
|
|||
sr_serial_dev_inst_free(serial);
|
||||
}
|
||||
g_free(devc);
|
||||
if (sdi)
|
||||
sr_dev_inst_free(sdi);
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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... */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue