X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=datastore.c;h=11ae0e15ce039d69efb6e8b93515536d4a0be211;hb=c8f4624d9b265f63bc880df28bd9b1a7e29f1488;hp=c7ace06faee0b104addce464750b2c4d044f6e4a;hpb=c49111295f0b2e50044923897d99ca84f65b75db;p=libsigrok.git diff --git a/datastore.c b/datastore.c index c7ace06f..11ae0e15 100644 --- a/datastore.c +++ b/datastore.c @@ -22,6 +22,7 @@ #include #include #include +#include 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;