simple implemetation of circular buffer in c