comparison th_datastruct.h @ 630:d3aace9903fa

Doxygen improvements.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 17 Jan 2020 19:32:28 +0200
parents b695eb769e30
children d5221299656a
comparison
equal deleted inserted replaced
629:b695eb769e30 630:d3aace9903fa
3 * Programmed and designed by Matti 'ccr' Hamalainen 3 * Programmed and designed by Matti 'ccr' Hamalainen
4 * (C) Copyright 2002-2020 Tecnic Software productions (TNSP) 4 * (C) Copyright 2002-2020 Tecnic Software productions (TNSP)
5 * 5 *
6 * Please read file 'COPYING' for information on license and distribution. 6 * Please read file 'COPYING' for information on license and distribution.
7 */ 7 */
8 /// @file
9 /// @brief Implementations of common data structures like linked lists, ring buffers, autogrowing buffers, etc.
8 #ifndef TH_DATASTRUCT_H 10 #ifndef TH_DATASTRUCT_H
9 #define TH_DATASTRUCT_H 11 #define TH_DATASTRUCT_H
10 12
11 #include "th_util.h" 13 #include "th_util.h"
12 14
13 #ifdef __cplusplus 15 #ifdef __cplusplus
14 extern "C" { 16 extern "C" {
15 #endif 17 #endif
16 18
17 19
18 /* Doubly linked list handling 20 /** @brief
21 * Doubly linked list structure.
19 */ 22 */
20 typedef struct _th_llist_t 23 typedef struct th_llist_t
21 { 24 {
22 size_t num; // Number of nodes in the list, meaningful ONLY in the current root node of the list 25 size_t num; ///< Number of nodes in the list, meaningful ONLY in the current root node of the list
23 struct _th_llist_t *prev, *next; 26 struct th_llist_t *prev, *next; ///< Pointers to previous and next nodes.
24 void *data; // Pointer to data payload of this node 27 void *data; ///< Pointer to data payload of this node, if any
25 } th_llist_t; 28 } th_llist_t;
26 29
27 30
28 th_llist_t * th_llist_new(void *data); 31 th_llist_t * th_llist_new(void *data);
29 void th_llist_free(th_llist_t *list); 32 void th_llist_free(th_llist_t *list);
47 50
48 th_llist_t * th_llist_find(th_llist_t *list, const void *data); 51 th_llist_t * th_llist_find(th_llist_t *list, const void *data);
49 th_llist_t * th_llist_find_func(th_llist_t *list, const void *userdata, int (compare)(const void *, const void *)); 52 th_llist_t * th_llist_find_func(th_llist_t *list, const void *userdata, int (compare)(const void *, const void *));
50 53
51 54
52 /* Ringbuffer implementation 55 /** @brief
56 * Ringbuffer data structure
53 */ 57 */
54 typedef struct 58 typedef struct
55 { 59 {
56 size_t n, size;
57 void (*deallocator)(void *data);
58 void **data; ///< Array of pointers to the data 60 void **data; ///< Array of pointers to the data
61 size_t size; ///< Size of this ringbuffer in elements (aka pointers to data)
62 size_t n; ///< Number of elements currently in the ringbuffer (@p n <= @p size)
63 void (*deallocator)(void *data); ///< De-allocator function that frees one element.
59 } th_ringbuf_t; 64 } th_ringbuf_t;
60 65
61 66
62 th_ringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *data)); 67 th_ringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *data));
63 BOOL th_ringbuf_grow(th_ringbuf_t *buf, const size_t n); 68 BOOL th_ringbuf_grow(th_ringbuf_t *buf, const size_t n);