]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi.c
sr_scpi_free(): Allow NULL as argument.
[libsigrok.git] / src / scpi / scpi.c
index 9ea68b57316db06ad8d324cef67c41016f867227..00f4ef805eb45843dfaf502942235c040b7f0bc2 100644 (file)
@@ -364,12 +364,14 @@ SR_PRIV int sr_scpi_close(struct sr_scpi_dev_inst *scpi)
 /**
  * Free SCPI device.
  *
- * @param scpi Previously initialized SCPI device structure.
- *
- * @return SR_OK on success, SR_ERR on failure.
+ * @param scpi Previously initialized SCPI device structure. If NULL,
+ *             this function does nothing.
  */
 SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi)
 {
+       if (!scpi)
+               return;
+
        scpi->free(scpi->priv);
        g_free(scpi->priv);
        g_free(scpi);