X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fcircularbytebuffer.h;h=917ee2acf6434d3f087383ec72cb0a876bc5e208;hb=2e0998249aeec3ce8509af80cc56fb6a49f3268d;hp=d1e40e4c8dca70663925e8ff597af4cf82a7120f;hpb=52ec168ece9d61bd9cb652235dfe8faee6232a11;p=avr-crypto-lib.git diff --git a/test_src/circularbytebuffer.h b/test_src/circularbytebuffer.h index d1e40e4..917ee2a 100644 --- a/test_src/circularbytebuffer.h +++ b/test_src/circularbytebuffer.h @@ -19,41 +19,65 @@ /** * \file circularbytebuffer.h * \email daniel.otte@rub.de - * \author Daniel Otte + * \author Daniel Otte * \date 2009-07-24 * \license GPLv3 or later - * \ingroup circularbytebuffer + * \addtogroup circularbytebuffer * \brief declaration for circular byte buffer */ - +/*@{*/ #ifndef CIRCULARBYTEBUFFER_H_ #define CIRCULARBYTEBUFFER_H_ #include #include #include "config.h" - + /** + * \brief type holding the managment information for the buffer + * + * A variable of this type may hold all the information to control the buffer + */ typedef struct { - uint8_t buffer_size; - uint8_t fillcount; - uint8_t* buffer; - uint8_t* head; - uint8_t* tail; - uint8_t* top; + uint8_t buffer_size; /**< holds the amount of bytes which may be stored in the buffer */ + uint8_t fillcount; /**< holds the amount of bytes actually stored in the buffer */ + uint8_t *buffer; /**< pointer to the actual buffer */ + uint8_t *head; /**< pointer to the head of the buffer */ + uint8_t *tail; /**< pointer to the tail of the buffer */ + uint8_t *top; /**< pointer to the last free address in the buffer */ } circularbytebuffer_t; #if CIRCULARBYTEBUFFER_NO_MALLOC==0 -uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb); +/** \brief buffer initialisation with automatic allocation + * + * This function initializes the given buffer context and allocates memory for + * it by calling malloc. + * \param buffersize size of the buffer to allocate + * \param cb buffer context to be initialized + */ +uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t *cb); #endif #if CIRCULARBYTEBUFFER_NO_INIT2==0 -void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer); +/** \brief buffer initialisation without automatic allocation + * + * This function initializes the given buffer context and uses the given buffer + * for storage, so no malloc is needed. + * \param buffersize size of the buffer + * \param cb buffer context to be initialized + * \param buffer buffer for the storage of data (you are responisble for allocation and freeing) + */ +void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t *cb, void *buffer); #endif -uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb); -uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb); -uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t* cb); -uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t* cb); -uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb); -void circularbytebuffer_free(circularbytebuffer_t* cb); +/** \brief + * + * + */ +uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t *cb); +uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t *cb); +uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t *cb); +uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t *cb); +uint8_t circularbytebuffer_cnt(circularbytebuffer_t *cb); +void circularbytebuffer_free(circularbytebuffer_t *cb); +/*@}*/ #endif /* CIRCULARBYTEBUFFER_H_ */