X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fhardware%2Fdcttech-usbrelay%2Fapi.c;fp=src%2Fhardware%2Fdcttech-usbrelay%2Fapi.c;h=deeb234a95eb2e72e640e6a3d0bcc8e2b9e328a6;hp=137277d0176b014758883bba82d988cd1c58a985;hb=d810901a45e01b8e79f6b269dbb931b538071953;hpb=7047acc8e85b38713450e800037dbcddb1fa98ac diff --git a/src/hardware/dcttech-usbrelay/api.c b/src/hardware/dcttech-usbrelay/api.c index 137277d0..deeb234a 100644 --- a/src/hardware/dcttech-usbrelay/api.c +++ b/src/hardware/dcttech-usbrelay/api.c @@ -63,6 +63,7 @@ static struct sr_dev_inst *probe_device_common(const char *path, struct channel_group_context *cgc; size_t idx, nr; struct sr_channel_group *cg; + char cg_name[24]; /* * Get relay count from product string. Weak condition, @@ -153,12 +154,11 @@ static struct sr_dev_inst *probe_device_common(const char *path, devc->relay_mask = (1U << relay_count) - 1; for (idx = 0; idx < devc->relay_count; idx++) { nr = idx + 1; - cg = g_malloc0(sizeof(*cg)); - cg->name = g_strdup_printf("R%zu", nr); + snprintf(cg_name, sizeof(cg_name), "R%zu", nr); cgc = g_malloc0(sizeof(*cgc)); - cg->priv = cgc; cgc->number = nr; - sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); + cg = sr_channel_group_new(sdi, cg_name, cgc); + (void)cg; } return sdi;