#define _ADT_H_
/**
- * \name Ring Buffer
+ * \name Ring Buffers
* \{
*/
typedef struct sRingBuffer
{
- size_t Start;
- size_t Length;
- size_t Space;
- char Data[];
+ size_t Start; //!< Start of data in ring buffer
+ size_t Length; //!< Number of data bytes in buffer
+ size_t Space; //!< Allocated space in buffer
+ char Data[]; //!< Buffer
} tRingBuffer;
/**
* \return Pointer to the buffer structure
*/
extern tRingBuffer *RingBuffer_Create(size_t Space);
+/**
+ * \brief Read at most \a Length bytes from the buffer
+ * \param Dest Destinaton buffer
+ * \param Buffer Source ring buffer
+ * \param Length Requested number of bytes
+ * \return Number of bytes read
+ */
extern size_t RingBuffer_Read(void *Dest, tRingBuffer *Buffer, size_t Length);
+/**
+ * \brief Write at most \a Length bytes to the buffer
+ * \param Buffer Destination ring buffer
+ * \param Source Source buffer
+ * \param Length Provided number of bytes
+ * \return Number of bytes written
+ */
extern size_t RingBuffer_Write(tRingBuffer *Buffer, void *Source, size_t Length);
/**
* \}