buffer.h (672B)
1 #ifndef __Loh3Ain3_{{BUFFER_PREFIX}}_H__ 2 #define __Loh3Ain3_{{BUFFER_PREFIX}}_H__ 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <stddef.h> 9 10 struct {{buffer_prefix}} { 11 char *alloc; 12 char *dat; 13 size_t len; 14 size_t cap; 15 }; 16 17 /** 18 * Append <length> bytes to the data in the buffer 19 * Copies the data, does not mutate the source 20 */ 21 void {{buffer_prefix}}_append(struct {{buffer_prefix}} *subject, const char *source, size_t length); 22 23 /** 24 * Remove <length> bytes from the front of the buffer 25 */ 26 size_t {{buffer_prefix}}_consume(struct {{buffer_prefix}} *subject, size_t length); 27 28 #ifdef __cplusplus 29 } // extern "C" 30 #endif 31 32 #endif // __Loh3Ain3_{{BUFFER_PREFIX}}_H__