From: Uwe Hermann Date: Sun, 9 May 2010 11:32:58 +0000 (+0200) Subject: datastore_new(): Use int as return value. X-Git-Tag: libsigrok-0.1.0~517 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2aebf78d9d10eb838b2fe58683d7af06015cd214;p=libsigrok.git datastore_new(): Use int as return value. --- diff --git a/datastore.c b/datastore.c index bb59fd58..75cd243b 100644 --- a/datastore.c +++ b/datastore.c @@ -25,24 +25,22 @@ static gpointer new_chunk(struct datastore **ds); -/* TODO: Return int as error status, and the struct as param. */ -struct datastore *datastore_new(int unitsize) +int datastore_new(int unitsize, struct datastore **ds) { - struct datastore *ds; + if (!ds) + return SIGROK_ERR; if (unitsize <= 0) - // return SIGROK_ERR; - return NULL; /* FIXME */ + return SIGROK_ERR; /* TODO: Different error? */ - if (!(ds = g_malloc(sizeof(struct datastore)))) - // return SIGROK_ERR_MALLOC; - return NULL; /* FIXME */ + if (!(*ds = g_malloc(sizeof(struct datastore)))) + return SIGROK_ERR_MALLOC; - ds->ds_unitsize = unitsize; - ds->num_units = 0; - ds->chunklist = NULL; + (*ds)->ds_unitsize = unitsize; + (*ds)->num_units = 0; + (*ds)->chunklist = NULL; - return ds; + return SIGROK_OK; } int datastore_destroy(struct datastore *ds) diff --git a/sigrok.h b/sigrok.h index bd1e8909..78f1567c 100644 --- a/sigrok.h +++ b/sigrok.h @@ -182,7 +182,7 @@ struct datastore { GSList *chunklist; }; -struct datastore *datastore_new(int unitsize); +int datastore_new(int unitsize, struct datastore **ds); int datastore_destroy(struct datastore *ds); void datastore_put(struct datastore *ds, void *data, unsigned int length, int in_unitsize, int *probelist);