]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-um: eliminate redundant data types in memory allocation
authorGerhard Sittig <redacted>
Wed, 15 Mar 2023 16:52:40 +0000 (17:52 +0100)
committerGerhard Sittig <redacted>
Thu, 16 Mar 2023 13:29:30 +0000 (14:29 +0100)
Just allocate the size of the involved variable. Eliminate redundant
data type specs where inconsistency would go unnoticed.

Link the device context earlier to the device instance while we are
here. Immediately after allocation of the dynamic memory so that the
relation remains obvious.

src/hardware/rdtech-um/api.c

index 863ba972cd99ea16807a709a05645db1ff45bf6a..3f086ae63f2a0e16518581b95bf3e1edde5f9917 100644 (file)
@@ -67,19 +67,18 @@ static GSList *rdtech_um_scan(struct sr_dev_driver *di,
                goto err_out_serial;
        }
 
                goto err_out_serial;
        }
 
-       devc = g_malloc0(sizeof(struct dev_context));
-       sdi = g_malloc0(sizeof(struct sr_dev_inst));
-
+       devc = g_malloc0(sizeof(*devc));
        sr_sw_limits_init(&devc->limits);
        devc->profile = p;
 
        sr_sw_limits_init(&devc->limits);
        devc->profile = p;
 
+       sdi = g_malloc0(sizeof(*sdi));
+       sdi->priv = devc;
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("RDTech");
        sdi->model = g_strdup(p->model_name);
        sdi->version = NULL;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup("RDTech");
        sdi->model = g_strdup(p->model_name);
        sdi->version = NULL;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-       sdi->priv = devc;
 
        for (ch_idx = 0; (name = p->channels[ch_idx].name); ch_idx++)
                sr_channel_new(sdi, ch_idx, SR_CHANNEL_ANALOG, TRUE, name);
 
        for (ch_idx = 0; (name = p->channels[ch_idx].name); ch_idx++)
                sr_channel_new(sdi, ch_idx, SR_CHANNEL_ANALOG, TRUE, name);