]> sigrok.org Git - libsigrok.git/commitdiff
vcd output: Eliminate unnecessary array of probe names.
authorMartin Ling <redacted>
Fri, 26 Apr 2013 22:00:51 +0000 (23:00 +0100)
committerBert Vermeulen <redacted>
Sat, 27 Apr 2013 13:49:50 +0000 (15:49 +0200)
output/vcd.c

index 27cc15336bf1422595ffce92be83ce4d99d7bbc7..0ede5fe7a42318bee28d83e481347107aff9fbab 100644 (file)
@@ -37,7 +37,6 @@
 
 struct context {
        int num_enabled_probes;
-       char *probelist[SR_MAX_NUM_PROBES + 1];
        int probeindices[SR_MAX_NUM_PROBES + 1];
        GString *header;
        uint8_t *prevsample;
@@ -71,7 +70,6 @@ static int init(struct sr_output *o)
                probe = l->data;
                if (!probe->enabled)
                        continue;
-               ctx->probelist[ctx->num_enabled_probes] = probe->name;
                ctx->probeindices[ctx->num_enabled_probes] = probe->index;
                ctx->num_enabled_probes++;
        }
@@ -81,7 +79,6 @@ static int init(struct sr_output *o)
        }
 
        ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
-       ctx->probelist[ctx->num_enabled_probes] = 0;
        ctx->header = g_string_sized_new(512);
        num_probes = g_slist_length(o->sdi->probes);
 
@@ -131,9 +128,12 @@ static int init(struct sr_output *o)
        g_string_append_printf(ctx->header, "$scope module %s $end\n", PACKAGE);
 
        /* Wires / channels */
-       for (i = 0; i < ctx->num_enabled_probes; i++) {
+       for (i = 0, l = o->sdi->probes; l; l = l->next, i++) {
+               probe = l->data;
+               if (!probe->enabled)
+                       continue;
                g_string_append_printf(ctx->header, "$var wire 1 %c %s $end\n",
-                               (char)('!' + i), ctx->probelist[i]);
+                               (char)('!' + i), probe->name);
        }
 
        g_string_append(ctx->header, "$upscope $end\n"