]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/openbench-logic-sniffer/protocol.c
Consistently use g_malloc0() for allocating devc.
[libsigrok.git] / src / hardware / openbench-logic-sniffer / protocol.c
index 0a816d01625ad238d7fb548007bd67903da09c76..584164e7ba412e02382b257ebc73a0339f4cebed 100644 (file)
@@ -124,10 +124,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
 {
        struct dev_context *devc;
 
-       if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               return NULL;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Device-specific settings */
        devc->max_samples = devc->max_samplerate = devc->protocol_version = 0;
@@ -152,7 +149,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
        GString *tmp_str, *devname, *version;
        guchar tmp_c;
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
+       sdi->status = SR_ST_INACTIVE;
        sdi->driver = di;
        devc = ols_dev_new();
        sdi->priv = devc;