TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: JAMES VAHN
from: DARRYL GREGORASH
date: 1998-01-20 11:44:00
subject: circular buffer

Replying to a message of James Vahn to Darryl Gregorash:
 JV>>> I don't think you described a circular buffer..  
 JV>>> Whadya mean: 'buffer is empty' head=tail ?  
 JV>>> That's a stacked buffer. 
 >> 
 >> Ummm.. a stack _is_ a LIFO buffer.. you read from and write
 >> to the stack using the "head" pointer. If you re-read, I
 >> said "write at the tail, read from the head", and that is a
 >> FIFO buffer, a queue.
 JV> LIFO,FIFO... the thing is in a circle. 
I know you didn't want to say this :) Whether or not the thing is circular 
has nothing to do with whether it is a stack or a queue.. that is determined 
by the pointer used to read, in relation to the pointer used to write. 
 JV> What if I'm reading
 JV> at the middle of it and a byte comes in?  Always drop it on
 JV> the oldest byte, reading has nothing to do with that.
 JV> You're going to need some more pointers.
Read my reply to Benjamin. I gave you two pointers.. the head and the tail. I 
even gave you a far pointer to the buffer itself, in case you want to pass it 
to a function by reference. If you are reading at the middle of a queue and a 
byte comes in, you write to the tail.. but you always read from the head for 
a queue.
If you have a stack, then you only need one pointer, unless you absolutely 
must preserve the first unread byte written to the stack (and I don't know 
why anyone would want to do that).. you always read and write using it. 
Increment and write, read and decrement.
BTW, the read_char function I posted doesn't work.. it stores the wrong value 
for the BUF_HEAD (it has the OFFSET of the buffer itself added, which is 
incorrect in that impmlementation). The corrected code is in my next msg.
--- FleetStreet 1.21 NR
---------------
* Origin: BIG BANG Burger Bar: Regina SK Canada (1:140/86)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.