a circular buffer written in c