hat-util  0.6.16
Utility library
ring.h
Go to the documentation of this file.
1 #ifndef HAT_RING_H
2 #define HAT_RING_H
3 
4 #include <stdint.h>
5 
6 #include "allocator.h"
7 
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 typedef struct hat_ring_t hat_ring_t;
14 
15 
18 
21 
22 // len/size is checked (head/tail can't skip each other)
23 void hat_ring_move_head(hat_ring_t *r, size_t len);
24 void hat_ring_move_tail(hat_ring_t *r, size_t len);
25 
26 // read/write copy data from/to ring and moves head/tail
27 size_t hat_ring_read(hat_ring_t *r, uint8_t *data, size_t data_len);
28 size_t hat_ring_write(hat_ring_t *r, uint8_t *data, size_t data_len);
29 
30 // returns used/unused ring data without modifing head/tail
31 void hat_ring_used(hat_ring_t *r, uint8_t *data[2], size_t data_len[2]);
32 void hat_ring_unused(hat_ring_t *r, uint8_t *data[2], size_t data_len[2]);
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #endif
Memory allocator.
void hat_ring_destroy(hat_ring_t *r)
void hat_ring_unused(hat_ring_t *r, uint8_t *data[2], size_t data_len[2])
void hat_ring_move_head(hat_ring_t *r, size_t len)
size_t hat_ring_size(hat_ring_t *r)
void hat_ring_move_tail(hat_ring_t *r, size_t len)
size_t hat_ring_write(hat_ring_t *r, uint8_t *data, size_t data_len)
void hat_ring_used(hat_ring_t *r, uint8_t *data[2], size_t data_len[2])
struct hat_ring_t hat_ring_t
Definition: ring.h:13
size_t hat_ring_len(hat_ring_t *r)
size_t hat_ring_read(hat_ring_t *r, uint8_t *data, size_t data_len)
hat_ring_t * hat_ring_create(hat_allocator_t *a, size_t size)
Allocator base struct.
Definition: allocator.h:36