memzap

replay memory writes
git clone git://git.2f30.org/memzap
Log | Files | Refs | README | LICENSE

ringbuffer.h (639B)


      1 #ifndef TERMBOX_RINGBUFFER_H
      2 #define TERMBOX_RINGBUFFER_H
      3 
      4 #define ERINGBUFFER_ALLOC_FAIL -1
      5 
      6 struct ringbuffer {
      7 	char *buf;
      8 	size_t size;
      9 
     10 	char *begin;
     11 	char *end;
     12 };
     13 
     14 int init_ringbuffer(struct ringbuffer *r, size_t size);
     15 void free_ringbuffer(struct ringbuffer *r);
     16 void clear_ringbuffer(struct ringbuffer *r);
     17 size_t ringbuffer_free_space(struct ringbuffer *r);
     18 size_t ringbuffer_data_size(struct ringbuffer *r);
     19 void ringbuffer_push(struct ringbuffer *r, const void *data, size_t size);
     20 void ringbuffer_pop(struct ringbuffer *r, void *data, size_t size);
     21 void ringbuffer_read(struct ringbuffer *r, void *data, size_t size);
     22 
     23 #endif