Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Circular buffers

2004-03-04 by Owen Mooney

Circular buufers are a technique not routines

Typical psuedocode:

    buffer[1024];
    int onpointer=0,offpointer=0;

    procedure addbyte(data) {
          buffer[onpointer]=data;
          onpointer++;
          onpointer= onpointer & 1023;
    }

    function getbyte() {
          res
          if (onpointer==offpointer)
                 return 0;   // no data available
          res=buffer[offpointer];
          offpointer++;
          offpointer=offpointer & 1023
          ret res;
     }

onpointer alwasy points the the first avaliable free space. offpointer 
always points to the next item avaliable

Owen

>Message: 11
>   Date: Wed, 3 Mar 2004 22:59:44 -0800
>   From: "Curt Powell" <curt.powell@...>
>Subject: Circular buffers
>
>Can someone point me to some circular buffer routines?
> 
>TIA,
> 
>Curt
> 
>
>  
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.