Re: [newbie?] Buffers

From: Patrick J. Dughi (dughi@IMAXX.NET)
Date: 07/28/97


> Sorry, but I don't know what a buffer is..., the only clue I have is that
> it holds information.  Would someone please enlighten me on the subject?
> So far, I haven't had any problems (that I know of) that has anything to
> do with buffers or such.., but it would answer questions like 'why would I
> use that buffer.c code that was just posted?'
> If it's not too much trouble, take the time and reply.
>

        A "buffer" is usually a pre-allocated space in memory, which is
used to hold temporary data. This buffer is just used for scratch
information like "Banzii hits the troll with a mindblowing pierce" or
whatever. Usually, buffer information lasts about as long as the function
that uses it (unlike character information, world info, etc..).  Now, the
main problems are threefold:
        1) if you use a global buffer (like circlemud has several of), you
have to make sure that its clean before you use it, else you'll get the
remenants of some other buffer info.
        2) You have to make sure that your buffers are correctly sized. If
they are NOT the correct size, you can overwrite them, which will make
everything in your mud act funny, and then end up in a happy mud crash, or
simply cause everything to just quit.
        3) Since these buffers are accessed SO much, it does become an
issue how fast they can be used. If the buffers need to be created each
and every time they're used, they will cause the program to run slowly. If
they are already created, you have to make sure they're the right size.
And if you're using more than one, you have to make sure that each one
gets the right one of the right size, else you cause more overhead if
other functions have to wait to use these buffers.

        Now, if i remember right (i have only had time to peruse the
code), the buffer code creates a bunch of buffers on demand, and stores
them for useage, cleans them when they're not in use.. stuff like that.
So, you don't have to make new buffers, or depend on incorrectly sized,
inefficent global buffers.  Ie, solves problems 1,2,3 above.

        Of course, I could be wrong. =)  Simply reviewing the code posted
should be able to describe its functionality.

                                                        PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST