]> sigrok.org Git - libsigrok.git/commitdiff
vcd output: Replace fixed length array of indices with GArray.
authorMartin Ling <redacted>
Fri, 26 Apr 2013 22:16:30 +0000 (23:16 +0100)
committerBert Vermeulen <redacted>
Sat, 27 Apr 2013 13:49:50 +0000 (15:49 +0200)
output/vcd.c

index 0ede5fe7a42318bee28d83e481347107aff9fbab..90493f05b88540e3f5e976c544b6b2fc6a5d95bc 100644 (file)
@@ -37,7 +37,7 @@
 
 struct context {
        int num_enabled_probes;
-       int probeindices[SR_MAX_NUM_PROBES + 1];
+       GArray *probeindices;
        GString *header;
        uint8_t *prevsample;
        int period;
@@ -65,12 +65,14 @@ static int init(struct sr_output *o)
 
        o->internal = ctx;
        ctx->num_enabled_probes = 0;
+       ctx->probeindices = g_array_new(FALSE, FALSE, sizeof(int));
 
        for (l = o->sdi->probes; l; l = l->next) {
                probe = l->data;
                if (!probe->enabled)
                        continue;
-               ctx->probeindices[ctx->num_enabled_probes] = probe->index;
+               ctx->probeindices = g_array_append_val(
+                               ctx->probeindices, probe->index);
                ctx->num_enabled_probes++;
        }
        if (ctx->num_enabled_probes > 94) {
@@ -188,7 +190,7 @@ static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi,
                sample = logic->data + i;
 
                for (p = 0; p < ctx->num_enabled_probes; p++) {
-                       index = ctx->probeindices[p % 8];
+                       index = g_array_index(ctx->probeindices, int, p);
                        curbit = (sample[p / 8] & (((uint8_t) 1) << index)) >> index;
                        prevbit = (ctx->prevsample[p / 8] & (((uint64_t) 1) << index)) >> index;