From: Sammy (samedi@DHC.NET)
Date: 09/10/97

On Wed, 10 Sep 1997, George wrote:

> >One of the problems with the details I'm having is that I figure I'll need
> >a lot of those buffer structures.  Right now I've got a system similar to
> >George's string buffer patch, where an output buffer struct is taken as
> >needed from a pool of preallocated buffers.  Using malloc to create
> Yup, except I allocate on demand now, although persistant ones are still
> allowed.

Yeah I'm doing the same for the most part.  If a function requests an
output buffer and none exist, it allocates X more buffers.  Later on I
want to add buffers when the free count is low and I've got some spare
time between pulses.  The big difference is I'm mallocing 10 at a time
since I'll be using so many.

> >Anyway, I've got the base setup working.  It just doesn't ever free the
> >buffers so once I hit the 'worst case', I'm stuck with that many buffers.
> Make a check_buffers() ccommand like my release_all_buffers();

It's not that simple.  I allocate 10 buffers at a time.  I can't free any
of those 10 individually.  I can only free the whole block (unless someone
knows some malloc/free tricks).  Since I keep a linked list of available
buffers and used buffers and move buffers between the two very often,
there's not much chance that given 10 free buffers they will all be in the
same block of memory.

I'm considering a used and free list for each block of buffers, but I was
hoping someone here would have some hints at a better way.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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