]> sigrok.org Git - libsigrok.git/blobdiff - datastore.c
Doxygen: Add @file items for the relevant files.
[libsigrok.git] / datastore.c
index 96d830b41294199b7bcbc5aac31fb0c3db9ffcb3..16346695a855b9f0f6be18938387ef9346c7dbcc 100644 (file)
 #include <stdint.h>
 #include <string.h>
 #include <glib.h>
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
+
+/**
+ * @file
+ *
+ * Creating, using, or destroying libsigrok datastores.
+ */
+
+/**
+ * @defgroup grp_datastore Datastore
+ *
+ * Creating, using, or destroying libsigrok datastores.
+ *
+ * @{
+ */
 
 static gpointer new_chunk(struct sr_datastore **ds);
 
@@ -36,8 +50,8 @@ static gpointer new_chunk(struct sr_datastore **ds);
  * It is the caller's responsibility to free the allocated memory of the
  * datastore via the sr_datastore_destroy() function, if no longer needed.
  *
- * TODO: Unitsize should probably be unsigned int or uint32_t or similar.
- * TODO: This function should have a 'chunksize' parameter, and
+ * @todo Unitsize should probably be unsigned int or uint32_t or similar.
+ * @todo This function should have a 'chunksize' parameter, and
  *       struct sr_datastore a 'chunksize' field.
  *
  * @param unitsize The unit size (>= 1) to be used for this datastore.
@@ -104,20 +118,20 @@ SR_API int sr_datastore_destroy(struct sr_datastore *ds)
 /**
  * Append some data to the specified datastore.
  *
- * TODO: More elaborate function description.
- *
- * TODO: This function should use the (not yet available) 'chunksize' field
+ * @todo More elaborate function description.
+ * @todo This function should use the (not yet available) 'chunksize' field
  *       of struct sr_datastore (instead of hardcoding DATASTORE_CHUNKSIZE).
- * TODO: in_unitsize and probelist are unused?
- * TODO: A few of the parameters can be const.
- * TODO: Ideally, 'ds' should be unmodified upon errors.
+ * @todo in_unitsize and probelist are unused?
+ * @todo A few of the parameters can be const.
+ * @todo Ideally, 'ds' should be unmodified upon errors.
+ * @todo Should 0 be allowed as length?
+ * @todo Specify/document the data format of the 'data' parameter.
  *
  * @param ds Pointer to the datastore which shall receive the data.
  *           Must not be NULL.
  * @param data Pointer to the memory buffer containing the data to add.
- *             Must not be NULL. TODO: Data format?
+ *             Must not be NULL.
  * @param length Length of the data to add (in number of bytes).
- *               TODO: Should 0 be allowed as length?
  * @param in_unitsize The unit size (>= 1) of the input data.
  * @param probelist Pointer to a list of integers (probe numbers). The probe
  *                  numbers in this list are 1-based, i.e. the first probe
@@ -128,16 +142,12 @@ SR_API int sr_datastore_destroy(struct sr_datastore *ds)
  *         is returned, the value/state of 'ds' is undefined.
  */
 SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
-               unsigned int length, int in_unitsize, int *probelist)
+               unsigned int length, int in_unitsize, const int *probelist)
 {
        unsigned int stored;
        int capacity, size, num_chunks, chunk_bytes_free, chunk_offset;
        gpointer chunk;
 
-       /* Avoid compiler warnings. */
-       (void)in_unitsize;
-       (void)probelist;
-
        if (!ds) {
                sr_err("ds: %s: ds was NULL", __func__);
                return SR_ERR_ARG;
@@ -219,9 +229,9 @@ SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
  *
  * The allocated memory is guaranteed to be cleared.
  *
- * TODO: This function should use the datastore's 'chunksize' field instead
+ * @todo This function should use the datastore's 'chunksize' field instead
  *       of hardcoding DATASTORE_CHUNKSIZE.
- * TODO: Return int, so we can return SR_OK / SR_ERR_ARG / SR_ERR_MALLOC?
+ * @todo Return int, so we can return SR_OK / SR_ERR_ARG / SR_ERR_MALLOC?
  *
  * @param ds Pointer to a variable which holds the datastore structure.
  *           Must not be NULL. The contents of 'ds' are modified in-place.
@@ -236,7 +246,8 @@ static gpointer new_chunk(struct sr_datastore **ds)
 
        chunk = g_try_malloc0(DATASTORE_CHUNKSIZE * (*ds)->ds_unitsize);
        if (!chunk) {
-               sr_err("ds: %s: chunk malloc failed", __func__);
+               sr_err("ds: %s: chunk malloc failed (ds_unitsize was %u)",
+                      __func__, (*ds)->ds_unitsize);
                return NULL; /* TODO: SR_ERR_MALLOC later? */
        }
 
@@ -244,3 +255,5 @@ static gpointer new_chunk(struct sr_datastore **ds)
 
        return chunk; /* TODO: SR_OK later? */
 }
+
+/** @} */