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;