uhf_buffer.h 545 B

12345678910111213141516171819202122
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <stddef.h>
  5. #define MAX_BUFFER_SIZE 200
  6. typedef struct Buffer {
  7. uint8_t* data;
  8. size_t size;
  9. size_t capacity;
  10. bool closed;
  11. } Buffer;
  12. Buffer* buffer_alloc(size_t inital_capacity);
  13. bool buffer_append_single(Buffer* buf, uint8_t value);
  14. bool buffer_append(Buffer* buf, uint8_t* data, size_t size);
  15. uint8_t* buffer_get_data(Buffer* buf);
  16. size_t buffer_get_size(Buffer* buf);
  17. void buffer_close(Buffer* buf);
  18. void buffer_reset(Buffer* buf);
  19. void buffer_free(Buffer* buf);