Circular buffer: Difference between revisions

Content deleted Content added
m improved style in the code example, changed a useless comment and corrected a constant definition. The entire section and the code example remains incorrect and misleading and I shall fix it fully if I find the time
Jdx (talk | contribs)
Circular buffer mechanics: Fixes in the C code
Line 70:
#define BUFLEN 3
 
int buf[BUFLEN]; /* array to be treated as circular buffer of BUFLEN integers */
int end = 0; /* write index */
int start = 0; /* read index */
Line 77:
{
buf[end++] = item;
end %= NBUFLEN;
}
 
Line 83:
{
int item = buf[start++];
start %= NBUFLEN;
return item;
}