30 int first = ring->
first;
31 int last = ring->
last;
33 return (last >= first) ? last - first : ring->
buffer_size - (first - last);
43 static void byte_move(
char *dest,
const char *src,
int n)
45 const char *last_p = dest + n;
46 while (dest < last_p) {
55 int push_size = (size > free_size) ? free_size : size;
62 int move_size = (to_end > push_size) ? push_size : to_end;
65 ring->
last += move_size;
68 left_size = push_size - move_size;
72 ring->
last = left_size;
77 ring->
last += push_size;
87 int pop_size = (size > now_size) ? now_size : size;
91 ring->
first += pop_size;
97 int move_size = (to_end > pop_size) ? pop_size : to_end;
100 ring->
first += move_size;
103 left_size = pop_size - move_size;
108 ring->
first = left_size;
int ring_size(const ring_buffer_t *ring)
格納データ数を返す
int ring_capacity(const ring_buffer_t *ring)
最大の格納データ数を返す
int ring_write(ring_buffer_t *ring, const char *data, int size)
データの格納
int ring_read(ring_buffer_t *ring, char *buffer, int size)
データの取り出し
void ring_initialize(ring_buffer_t *ring, char *buffer, const int shift_length)
初期化
void ring_clear(ring_buffer_t *ring)
リングバッファのクリア
static void byte_move(char *dest, const char *src, int n)