#ifndef LIB_RINGBUF_H
#define LIB_RINGBUF_H

#include <stdint.h>

typedef struct
{
    unsigned char  *pHead;//环形存储区的首地址
    unsigned char  *pTail;//环形存储区的结尾地址   
    unsigned char  *pValid;//已使用的缓冲区的首地址
    unsigned char  *pValidTail;//已使用的缓冲区的尾地址
    unsigned int 		pop_size;
    unsigned int 		push_size;
    unsigned int   	size;
} RingBufOBJ;

typedef RingBufOBJ* RingBuf;

RingBuf RingBuf_Init(RingBufOBJ *data, void *buffer, int buff_size);
void RingBuf_Fini(RingBufOBJ *data);
int RingBuf_Push(RingBuf Object, const void *data, int size);
int RingBuf_Peek(RingBuf Object, void *data, int size); //返回实际尺寸
int RingBuf_Pop(RingBuf Object, void *data, int size);
uint32_t RingBuf_obj_num(RingBuf Object,int obj_size);
#endif 
