I have nearly completed a dynamic buffer allocation and reallocation system for writing large amounts of text into a buffer without worry of overflowing it. To utilize this with circle, you would have to rewrite some sections of your code. If there is any interest in this kind of thing I would be happy to make it available. It will just be a module that you can install, not a patch. Some Features: 1. Allows you to create as many buffers as you like. 2. Prevents seg faults caused by buffer overflowing. 3. Ensures that no 2 functions ever try to write to the same global buffer. 4. Reduces the memory overhead of large global buffers (a buffer is only as big as it needs to be). 5. Automatically reallocates a buffer if more space is needed. This is configurable, each time it allocates or reallocates it does it by a fixed amount. You can configure this amount for either optimal speed or optimal memory use. 6. Unused buffers consume no memory. Here is a list of functions that you can use: typedef long BUF; /* a buffer handle is just a long int */ /* Allocate space for a new buffer and return the handle */ BUF newbuf(void); /* given a buffer handle return the string associated with it */ char *buftos(BUF); /* copy a string into a buffer */ BUF bufcpy(BUF, char *); /* concatenate a string to the end of a buffer */ BUF bufcat(BUF, char *); /* When finished, you must free buffers */ void bfree(BUF); /* Works like sprintf but prints into a buffer instead of a string */ int bprintf(BUF, const char *, ...); /* Initializes the bufferlist. Must be called before anything else, */ /* but only needs to be called once */ void initbufs(void); I will probably add some more stuff to this, things that are in the ANSI string library and support for reading from a file to a buffer like sscanf(). If there is any interest in using something like this let me know and I will give it to George. :-) ( If George would have it :-P ) --Sean ---- /'''''''''''''''''\'\ The final aspiration of all coders? | | | | /* Sean Butler */ | | Sean Butler | | | Coder for finality.com 4000 | exit(0); | | Xin@finality.com | | | | | | \\//................\\\// +------------------------------------------------------------+ | 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