]> sigrok.org Git - libsigrok.git/blobdiff - output/text/text.c
Suppress compile warning
[libsigrok.git] / output / text / text.c
index a2b8b20ec0962ee2baf11e000d5e549c2ecb57e9..7263224d1874f65c8df2bac2b3e0066f49dc2571 100644 (file)
@@ -129,8 +129,8 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
 
        snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
        num_probes = g_slist_length(o->sdi->probes);
-       if (sr_config_get(o->sdi->driver, SR_CONF_SAMPLERATE, &gvar,
-                       o->sdi) == SR_OK) {
+       if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
+                       &gvar) == SR_OK) {
                samplerate = g_variant_get_uint64(gvar);
                g_variant_unref(gvar);
                if (!(samplerate_s = sr_samplerate_string(samplerate))) {
@@ -171,6 +171,31 @@ err:
        return ret;
 }
 
+SR_PRIV int text_cleanup(struct sr_output *o)
+{
+       struct context *ctx;
+
+       if (!o)
+               return SR_ERR_ARG;
+
+       ctx = o->internal;
+
+       g_free(ctx->header);
+       g_free(ctx->linebuf);
+       g_free(ctx->linevalues);
+
+       if (ctx->prevsample)
+               g_free(ctx->prevsample);
+
+       g_slist_free(ctx->probenames);
+
+       g_free(ctx);
+
+       o->internal = NULL;
+
+       return SR_OK;
+}
+
 SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
                  uint64_t *length_out)
 {
@@ -195,8 +220,6 @@ SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
                flush_linebufs(ctx, outbuf);
                *data_out = outbuf;
                *length_out = strlen((const char *)outbuf);
-               g_free(o->internal);
-               o->internal = NULL;
                break;
        default:
                *data_out = NULL;