clean code and add ring_buf.c