X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=output%2Ftext%2Ftext.c;h=47d0542b889e2bf4d2639c36764a04d725daca98;hb=67d6f6fca2b85f2ef6a7e03383ebdcd2ce877eab;hp=9be3397400f41c56c384c9bc8874d23337946ab0;hpb=d3c74a6fb05118e32ad421443251b7b3288918f9;p=libsigrok.git diff --git a/output/text/text.c b/output/text/text.c index 9be33974..47d0542b 100644 --- a/output/text/text.c +++ b/output/text/text.c @@ -27,14 +27,7 @@ #include "libsigrok-internal.h" #include "text.h" -/* Message logging helpers with subsystem-specific prefix string. */ -#define LOG_PREFIX "output/text: " -#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) -#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args) -#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args) -#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args) -#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) -#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) +#define LOG_PREFIX "output/text" SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf) { @@ -99,6 +92,8 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode) for (l = o->sdi->probes; l; l = l->next) { probe = l->data; + if (probe->type != SR_PROBE_LOGIC) + continue; if (!probe->enabled) continue; ctx->probenames = g_slist_append(ctx->probenames, probe->name); @@ -171,6 +166,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 +215,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;