libsigrok
|
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <glib.h>
#include "sigrok.h"
#include "sigrok-internal.h"
Go to the source code of this file.
Functions | |
SR_API int | sr_datastore_new (int unitsize, struct sr_datastore **ds) |
Create a new datastore with the specified unit size. | |
SR_API int | sr_datastore_destroy (struct sr_datastore *ds) |
Destroy the specified datastore and free the memory used by it. | |
SR_API int | sr_datastore_put (struct sr_datastore *ds, void *data, unsigned int length, int in_unitsize, const int *probelist) |
Append some data to the specified datastore. |
SR_API int sr_datastore_destroy | ( | struct sr_datastore * | ds | ) |
Destroy the specified datastore and free the memory used by it.
This will free the memory used by the data in the datastore's 'chunklist', by the chunklist data structure itself, and by the datastore struct.
ds | The datastore to destroy. |
Definition at line 86 of file datastore.c.
References sr_datastore::chunklist, sr_err(), SR_ERR_ARG, and SR_OK.
SR_API int sr_datastore_new | ( | int | unitsize, |
struct sr_datastore ** | ds | ||
) |
Create a new datastore with the specified unit size.
The unit size is fixed once the datastore is created, and cannot be changed later on, neither can data be added to the datastore with different unit sizes later.
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 struct sr_datastore a 'chunksize' field.
unitsize | The unit size (>= 1) to be used for this datastore. |
ds | Pointer to a variable which will hold the newly created datastore structure. |
Definition at line 51 of file datastore.c.
References sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.
SR_API int sr_datastore_put | ( | struct sr_datastore * | ds, |
void * | data, | ||
unsigned int | length, | ||
int | in_unitsize, | ||
const int * | probelist | ||
) |
Append some data to the specified datastore.
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.
ds | Pointer to the datastore which shall receive the data. Must not be NULL. |
data | Pointer to the memory buffer containing the data to add. Must not be NULL. TODO: Data format? |
length | Length of the data to add (in number of bytes). TODO: Should 0 be allowed as length? |
in_unitsize | The unit size (>= 1) of the input data. |
probelist | Pointer to a list of integers (probe numbers). The probe numbers in this list are 1-based, i.e. the first probe is expected to be numbered 1 (not 0!). Must not be NULL. |
Definition at line 130 of file datastore.c.
References sr_datastore::chunklist, sr_datastore::ds_unitsize, sr_datastore::num_units, sr_err(), SR_ERR_ARG, SR_ERR_MALLOC, and SR_OK.