comparison th_datastruct.h @ 453:efd33accdc81

Break backwards compatibility by renaming BOOL, TRUE and FALSE to lowercase. Introduce optional but default use of stdbool.h.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Jan 2018 22:56:03 +0200
parents 6d29aaeab290
children 347bfd3e017e
comparison
equal deleted inserted replaced
452:4471eadea472 453:efd33accdc81
58 int n, size; 58 int n, size;
59 void (*deallocator)(void *); 59 void (*deallocator)(void *);
60 } th_ringbuf_t; 60 } th_ringbuf_t;
61 61
62 th_ringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *)); 62 th_ringbuf_t * th_ringbuf_new(const size_t size, void (*mdeallocator)(void *));
63 BOOL th_ringbuf_grow(th_ringbuf_t *buf, const size_t n); 63 bool th_ringbuf_grow(th_ringbuf_t *buf, const size_t n);
64 void th_ringbuf_free(th_ringbuf_t *buf); 64 void th_ringbuf_free(th_ringbuf_t *buf);
65 void th_ringbuf_add(th_ringbuf_t *buf, void *ptr); 65 void th_ringbuf_add(th_ringbuf_t *buf, void *ptr);
66 66
67 67
68 /* Growing buffers 68 /* Growing buffers
70 #define TH_BUFGROW (32) 70 #define TH_BUFGROW (32)
71 71
72 72
73 typedef struct 73 typedef struct
74 { 74 {
75 BOOL allocated; 75 bool allocated;
76 uint8_t *data; 76 uint8_t *data;
77 size_t size, len, mingrow; 77 size_t size, len, mingrow;
78 } th_growbuf_t; 78 } th_growbuf_t;
79 79
80 80
81 /* Simple growing string buffer 81 /* Simple growing string buffer
82 */ 82 */
83 BOOL th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow); 83 bool th_strbuf_grow(char **buf, size_t *bufsize, size_t *len, const size_t grow);
84 BOOL th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch); 84 bool th_strbuf_putch(char **buf, size_t *bufsize, size_t *len, const char ch);
85 BOOL th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen); 85 bool th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen);
86 BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str); 86 bool th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str);
87 87
88 88
89 /* Growing byte buffer 89 /* Growing byte buffer
90 */ 90 */
91 void th_growbuf_init(th_growbuf_t *buf, const size_t mingrow); 91 void th_growbuf_init(th_growbuf_t *buf, const size_t mingrow);
92 void th_growbuf_clear(th_growbuf_t *buf); 92 void th_growbuf_clear(th_growbuf_t *buf);
93 th_growbuf_t *th_growbuf_new(const size_t mingrow); 93 th_growbuf_t *th_growbuf_new(const size_t mingrow);
94 void th_growbuf_free(th_growbuf_t *buf); 94 void th_growbuf_free(th_growbuf_t *buf);
95 95
96 96
97 BOOL th_growbuf_grow(th_growbuf_t *buf, const size_t grow); 97 bool th_growbuf_grow(th_growbuf_t *buf, const size_t grow);
98 BOOL th_growbuf_puts(th_growbuf_t *buf, const char *str, BOOL eos); 98 bool th_growbuf_puts(th_growbuf_t *buf, const char *str, bool eos);
99 BOOL th_growbuf_putch(th_growbuf_t *buf, const char ch); 99 bool th_growbuf_putch(th_growbuf_t *buf, const char ch);
100 BOOL th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len); 100 bool th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len);
101 BOOL th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val); 101 bool th_growbuf_put_u8(th_growbuf_t *buf, const uint8_t val);
102 BOOL th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val); 102 bool th_growbuf_put_u16_be(th_growbuf_t *buf, const uint16_t val);
103 BOOL th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val); 103 bool th_growbuf_put_u16_le(th_growbuf_t *buf, const uint16_t val);
104 BOOL th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val); 104 bool th_growbuf_put_u32_be(th_growbuf_t *buf, const uint32_t val);
105 BOOL th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val); 105 bool th_growbuf_put_u32_le(th_growbuf_t *buf, const uint32_t val);
106 106
107 107
108 #ifdef __cplusplus 108 #ifdef __cplusplus
109 } 109 }
110 #endif 110 #endif