A fast fixed-size buffer. which you can pretend is "infinite memory" for data that you don't care too much about. When you write to it, it fills up until you start overwriting the oldest data. When reading, it returns the oldest data it has. Ideal for buffering data anywhere a bandwidth is a problem, like text input when you have a low framerate, or streaming real-time sound or video where the past doesn't matter too much. [code] #define BUFFER_SIZE 256 item *buffer[BUFFER_SIZE]; int start = 0; int end = 0 int active = 0; void PushToQueue(item *p) { buffer[end] = p; end = (end + 1) % BUFFER_SIZE; if (active < BUFFER_SIZE) { active++; } else { /* Overwriting the oldest. Move start to next-oldest */ start = (start + 1) % BUFFER_SIZE } } item *RetrieveFromQueue(void) { item *p; if (!active) { return NULL; } p = buffer[start]; start = (start + 1) % BUFFER_SIZE; active--; return p; } [/code] It looks simple, but was a helluva thing to implement as the intuitive solutions (like checking if start == end for detecting emptiness) don't work. So hopefully it saves somebody else the trouble! If you like syntax highlighting, [url=http://www.tophatstuff.co.uk/?p=116]syntax highlighted version[/url] (needs JavaScript) This post is from -- http://socoder.net/index.php?topic=0