-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathringbuffer.h
More file actions
31 lines (23 loc) · 836 Bytes
/
ringbuffer.h
File metadata and controls
31 lines (23 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Only support one reader and one writer
* Protected by MIT license:
* https://mit-license.org/
*/
#ifndef _RING_BUFFER_H_
#define _RING_BUFFER_H_
#ifdef __cplusplus
extern "C" {
#endif
/* malloc ring buffer, return value will be used by other function */
void *rb_malloc(unsigned int buffer_size);
/* free ring buffer */
void rb_free(void *rb);
/* read ring buffer, when accept_partial is NULL, must read len or never read */
/* return value: readed bytes indeed */
unsigned int rb_read(void *rb, void *buffer, unsigned int len, int accept_partial);
/* write ring buffer, when accept_partial is NULL, must write len or never write */
/* return value: writed bytes indeed */
unsigned int rb_write(void *rb, void *buffer, unsigned int len, int accept_partial);
#ifdef __cplusplus
}
#endif
#endif