FreeRDP
ringbuffer.h
1 
20 #ifndef FREERDP_UTILS_RINGBUFFER_H
21 #define FREERDP_UTILS_RINGBUFFER_H
22 
23 #include <winpr/wtypes.h>
24 #include <freerdp/api.h>
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
32  typedef struct
33  {
34  size_t initialSize;
35  size_t freeSize;
36  size_t size;
37  size_t readPtr;
38  size_t writePtr;
39  BYTE* buffer;
40  } RingBuffer;
41 
43  typedef struct
44  {
45  size_t size;
46  const BYTE* data;
47  } DataChunk;
48 
55  FREERDP_API BOOL ringbuffer_init(RingBuffer* rb, size_t initialSize);
56 
62  FREERDP_API void ringbuffer_destroy(RingBuffer* ringbuffer);
63 
70  FREERDP_API size_t ringbuffer_used(const RingBuffer* ringbuffer);
71 
77  FREERDP_API size_t ringbuffer_capacity(const RingBuffer* ringbuffer);
78 
87  FREERDP_API BOOL ringbuffer_write(RingBuffer* rb, const BYTE* ptr, size_t sz);
88 
96  FREERDP_API BYTE* ringbuffer_ensure_linear_write(RingBuffer* rb, size_t sz);
97 
107  FREERDP_API BOOL ringbuffer_commit_written_bytes(RingBuffer* rb, size_t sz);
108 
117  FREERDP_API int ringbuffer_peek(const RingBuffer* rb, DataChunk chunks[2], size_t sz);
118 
125  FREERDP_API void ringbuffer_commit_read_bytes(RingBuffer* rb, size_t sz);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* FREERDP_UTILS_RINGBUFFER_H */
a piece of data in the ring buffer, exactly like a glibc iovec
Definition: ringbuffer.h:44
ring buffer meta data
Definition: ringbuffer.h:33