Code:
isfull
if num allocated >= buffer size
return full
else
return not full
That's basically how you want to check for fullness. If you're using globals, you don't really need to pass it anything, provided you're remembering to actually increase the number allocated when you do allocate something.
Code:
getnew
if not isfull
return buffer[ currentposition ++ ]
else
return full
Basically all you want to do is return the current spot, and update the current position. How you exactly do that is up to you, but it goes basically something like that.
Code:
freelast
if not isempty
return (buffer[ tail-- ] = 0)
else
return failure
Similar to allocating, you probably want to return some indicator of success or failure. Not that you really need to return anything at all.
It doesn't really matter what you call tail or currentposition, or whatever. You just need to make sure you update your actual variables correctly. I'm not sure why you even really need a circular buffer, if all you're doing is freeing the last thing allocated. I mean, it's not like you're ever going to go below zero, and it's not like you're going to ever go above the top.
Quzah.