Buffer.h 461 B

12345678910111213141516171819
  1. #ifndef CORE_BUFFER_H
  2. #define CORE_BUFFER_H
  3. #include <stddef.h>
  4. typedef struct {
  5. size_t size;
  6. size_t capacity;
  7. char* buffer;
  8. } Buffer;
  9. void initBuffer(Buffer* b);
  10. void destroyBuffer(Buffer* b);
  11. void addSizedBufferData(Buffer* b, const void* data, size_t size);
  12. #define addTypedBufferData(buffer, type, ...) \
  13. addSizedBufferData(buffer, &(type){__VA_ARGS__}, sizeof(type))
  14. void clearBuffer(Buffer* b);
  15. #endif