X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Foutput%2Fcsv.c;h=c4801ef7f984bca96b432fda2eb37c55fd9da730;hb=HEAD;hp=49d6eb6ec457ea2b211aaab4e897cbd72ce4566c;hpb=ce384e074f41685bad83c3cef10ea1d635a2834d;p=libsigrok.git diff --git a/src/output/csv.c b/src/output/csv.c index 49d6eb6e..c4801ef7 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -252,11 +252,13 @@ static GString *gen_header(const struct sr_output *o, /* Some metadata */ if (ctx->header && !ctx->did_header) { /* save_gnuplot knows how many lines we print. */ + time_t secs; + secs = hdr->starttime.tv_sec; g_string_append_printf(header, "%s CSV generated by %s %s\n%s from %s on %s", ctx->comment, PACKAGE_NAME, sr_package_version_string_get(), ctx->comment, - ctx->title, ctime(&hdr->starttime.tv_sec)); + ctx->title, ctime(&secs)); /* Columns / channels */ channels = o->sdi ? o->sdi->channels : NULL; @@ -420,7 +422,8 @@ static void dump_saved_values(struct context *ctx, GString **out) } else { sr_info("Dumping %u samples", ctx->num_samples); - *out = g_string_sized_new(512); + if (!*out) + *out = g_string_sized_new(512); num_channels = ctx->num_logic_channels + ctx->num_analog_channels; @@ -678,6 +681,7 @@ static int receive(const struct sr_output *o, ctx->trigger = TRUE; break; case SR_DF_LOGIC: + *out = g_string_sized_new(512); logic = packet->payload; ctx->pkt_snums = logic->length; ctx->pkt_snums /= logic->length; @@ -685,6 +689,7 @@ static int receive(const struct sr_output *o, process_logic(ctx, logic); break; case SR_DF_ANALOG: + *out = g_string_sized_new(512); analog = packet->payload; ctx->pkt_snums = analog->num_samples; ctx->pkt_snums /= g_slist_length(analog->meaning->channels);