libdacav 0.9.0
|
This module provides a trivial implementation of fixed size circular buffers. More...
Typedefs | |
typedef struct dcirc | dcirc_t |
Opaque type for circular buffer. | |
Enumerations | |
enum | dcirc_result_t { DCIRC_SUCCESS = 0, DCIRC_EMPTY = 1 } |
Return value for the getter function. More... | |
Functions | |
dcirc_t * | dcirc_new (size_t size, const dcprm_t *cprm) |
Constructor for a circular buffer. | |
dcirc_result_t | dcirc_get (dcirc_t *cb, void **item) |
Getter for the oldest item. | |
void | dcirc_put (dcirc_t *cb, const void *item) |
Insert an item, possibly overwriting the oldest stored item. | |
void | dcirc_flush (dcirc_t *cb) |
Flush the circular buffer. | |
void | dcirc_free (dcirc_t *cb) |
Destructor for a circular buffer. |
This module provides a trivial implementation of fixed size circular buffers.
typedef struct dcirc dcirc_t |
Opaque type for circular buffer.
enum dcirc_result_t |
Return value for the getter function.
void dcirc_flush | ( | dcirc_t * | cb | ) |
Flush the circular buffer.
All internal items are removed according to the given remotion semantics.
[in] | cb | The circular buffer to be freed. |
void dcirc_free | ( | dcirc_t * | cb | ) |
Destructor for a circular buffer.
The buffer is automatically flushed before getting freed.
[in] | cb | The circular buffer to destroy. |
dcirc_result_t dcirc_get | ( | dcirc_t * | cb, |
void ** | item | ||
) |
Getter for the oldest item.
The oldest item (if any) gets removed from the circualr buffer, and its ownership gets trasferred to the caller.
[in] | cb | The circular buffer; |
[out] | item | The retrieved item. |
dcirc_result_t::DCIRC_SUCCESS | on success; |
dcirc_result_t::DCIRC_EMPTY | if nothing is stored into the buffer. |
Constructor for a circular buffer.
[in] | size | The number of consecutive elements stored into the circular buffer; |
[in] | cprm | The copy-constructor/destructor pair for items. You may provide NULL in order to avoid a copying semantics. |
void dcirc_put | ( | dcirc_t * | cb, |
const void * | item | ||
) |
Insert an item, possibly overwriting the oldest stored item.
The inserted item gets copied through the provided copy semantics. The overwritten item, if any, gets freed through the provided remotion semantics.
[in] | cb | The circular buffer; |
[in] | item | The item to be inserted. |