]> sigrok.org Git - libsigrok.git/blobdiff - datastore.c
Improve sr_filter_probes error handling and docs.
[libsigrok.git] / datastore.c
index c7ace06faee0b104addce464750b2c4d044f6e4a..774ec08cd2cf0555cf037d7fd8e50d27ea4a12c9 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <glib.h>
 #include <sigrok.h>
+#include <sigrok-internal.h>
 
 static gpointer new_chunk(struct sr_datastore **ds);
 
@@ -33,8 +34,10 @@ int sr_datastore_new(int unitsize, struct sr_datastore **ds)
        if (unitsize <= 0)
                return SR_ERR; /* TODO: Different error? */
 
-       if (!(*ds = g_malloc(sizeof(struct sr_datastore))))
+       if (!(*ds = g_try_malloc(sizeof(struct sr_datastore)))) {
+               sr_err("ds: %s: ds malloc failed", __func__);
                return SR_ERR_MALLOC;
+       }
 
        (*ds)->ds_unitsize = unitsize;
        (*ds)->num_units = 0;
@@ -66,8 +69,8 @@ void sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
        gpointer chunk;
 
        /* Avoid compiler warnings. */
-       in_unitsize = in_unitsize;
-       probelist = probelist;
+       (void)in_unitsize;
+       (void)probelist;
 
        if (ds->chunklist == NULL)
                chunk = new_chunk(&ds);