]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/chronovu-la/api.c
rigol-ds: Fix wrong channel group malloc size.
[libsigrok.git] / src / hardware / chronovu-la / api.c
index b31db039b0f18420e8336349572f22096f41e652..14f1066eaa8809a565f2744d7aa9780bcf31d88a 100644 (file)
@@ -80,14 +80,13 @@ static int add_device(int idx, int model, GSList **devices)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
 
        ret = SR_OK;
 
        drvc = di->priv;
 
        /* Allocate memory for our private device context. */
-       devc = g_try_malloc(sizeof(struct dev_context));
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Set some sane defaults. */
        devc->prof = &cv_profiles[model];
@@ -127,14 +126,9 @@ static int add_device(int idx, int model, GSList **devices)
        sdi->driver = di;
        sdi->priv = devc;
 
-       for (i = 0; i < devc->prof->num_channels; i++) {
-               if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
-                                         cv_channel_names[i]))) {
-                       ret = SR_ERR;
-                       goto err_free_dev_inst;
-               }
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
+       for (i = 0; i < devc->prof->num_channels; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
+                                   cv_channel_names[i]);
 
        *devices = g_slist_append(*devices, sdi);
        drvc->instances = g_slist_append(drvc->instances, sdi);
@@ -142,9 +136,6 @@ static int add_device(int idx, int model, GSList **devices)
        if (ret == SR_OK)
                return SR_OK;
 
-err_free_dev_inst:
-       sr_dev_inst_free(sdi);
-       g_free(devc->final_buf);
 err_free_devc:
        g_free(devc);