]> sigrok.org Git - libsigrok.git/blobdiff - src/input/input.c
input: sr_input_free() is now a void function.
[libsigrok.git] / src / input / input.c
index 02f7db1b928c92bbed73f15e115d725c48c7b238..3547d9e1800888cbe62473920b8ba5f19343126d 100644 (file)
@@ -530,31 +530,40 @@ SR_API int sr_input_send(const struct sr_input *in, GString *buf)
 }
 
 /**
- * Free the specified input instance and all associated resources.
+ * Signal the input module no more data will come.
+ *
+ * This will cause the module to process any data it may have buffered.
+ * The SR_DF_END packet will also typically be sent at this time.
  *
  * @since 0.4.0
  */
-SR_API int sr_input_free(const struct sr_input *in)
+SR_API int sr_input_end(const struct sr_input *in)
 {
-       int ret;
+       sr_spew("Calling end() on %s module.", in->module->id);
+       return in->module->end((struct sr_input *)in);
+}
 
+/**
+ * Free the specified input instance and all associated resources.
+ *
+ * @since 0.4.0
+ */
+SR_API void sr_input_free(const struct sr_input *in)
+{
        if (!in)
-               return SR_ERR_ARG;
+               return;
 
-       ret = SR_OK;
        if (in->module->cleanup)
-               ret = in->module->cleanup((struct sr_input *)in);
+               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... */
                sr_warn("Found %d unprocessed bytes at free time.", in->buf->len);
        }
-       if (in->buf)
-               g_string_free(in->buf, TRUE);
+       g_string_free(in->buf, TRUE);
+       g_free(in->priv);
        g_free((gpointer)in);
-
-       return ret;
 }