snprintf()

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 08/26/97


Currently my buffer system returns a char * so that functions can use it as
they have always except for freeing it.

To take advantage of the run-time size stored in the structure, we have to
pass back the entire structure of buf_data.  That is not a problem, I made
up a quick bprintf() that uses the buf_data structure transparently just
like sprintf(), in fact I did a #define sprintf bprintf.

The only problem is that each and every other function in CircleMUD doesn't
use the struct buf_data but a char *.  So after going about changing things
to a typedef'd buffer *, I ran into the problem that while sprintf is
easily changed, functions such as log() that take constants cannot be
modified as such.  send_to_char() is another problem in that regard.

I'd like to know if anyone has suggestions on how to approach this.
Currently I'm thinking that any string handling functions like spriotf()
strcpy() and such should be changed but everything else should still pass
around char *'s if they do not modify the strings (const char *
designations would be nice).  The only problem with that is that then
strcpy() can also take a constant as a second argument.  I already know of
an approach to this in C++ but it does not seem so easy in plain C.  Or
should I just leave the code as it is, returning a char * and then work on
preparing it to be converting into a class, still being able to use it's
corruption handling, size checking, and dynamic adjustment capabilities?

--
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | 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