axle OS
x86_32 UNIX-like hobby OS
src
std
circular_buffer.h
1
#ifndef CIRCULAR_BUF_H
2
#define CIRCULAR_BUF_H
3
4
#include <stdint.h>
5
#define size_t uint32_t
6
7
typedef
struct
circular_buffer
{
8
char
*buffer;
// data buffer
9
char
*buffer_end;
// end of data buffer
10
size_t
capacity;
// maximum number of items in the buffer
11
size_t
count;
// number of items in the buffer
12
size_t
sz;
// size of each item in the buffer
13
char
*head;
// pointer to head
14
char
*tail;
// pointer to tail
15
}
circular_buffer
;
16
17
void
cb_init(
circular_buffer
*cb,
size_t
capacity,
size_t
sz);
18
void
cb_free(
circular_buffer
*cb);
19
void
cb_push_back(
circular_buffer
*cb,
const
char
*item);
20
void
cb_pop_front(
circular_buffer
*cb,
char
*item);
21
void
cb_peek(
circular_buffer
*cb,
char
*item);
22
23
#endif
circular_buffer
Definition:
circular_buffer.h:7
Generated by
1.8.14