diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-06 04:25:13 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-06 04:25:13 +0000 |
commit | 49b620d06a9b5c835e97aa238b42d5d56743e6fb (patch) | |
tree | 878e65578a3c75ed21143c1fc3d5c18e0eceade3 /src/common/utils.c | |
parent | 8d11ccf2e1bd71bde6d765bebe7f8a4ac0bc5d2f (diff) | |
download | hercules-49b620d06a9b5c835e97aa238b42d5d56743e6fb.tar.gz hercules-49b620d06a9b5c835e97aa238b42d5d56743e6fb.tar.bz2 hercules-49b620d06a9b5c835e97aa238b42d5d56743e6fb.tar.xz hercules-49b620d06a9b5c835e97aa238b42d5d56743e6fb.zip |
- Added StringBuf_Vprintf to utils.c and changed the showmsg.c buffer.
Now it uses a static buffer and a StringBuf when needed (a debug message indicating the static buffer needs to be increased is shown).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9414 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/utils.c')
-rw-r--r-- | src/common/utils.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/common/utils.c b/src/common/utils.c index 3172e89d9..c7b3b517a 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -155,18 +155,15 @@ void StringBuf_Init(struct StringBuf * sbuf) { sbuf->ptr_ = sbuf->buf_ = (char *) aMallocA(sbuf->max_ + 1); } -// printf into a StringBuf, moving the pointer [MouseJstr] -int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...) +// vprintf into a StringBuf, moving the pointer [MouseJstr] +int StringBuf_Vprintf(struct StringBuf *sbuf,const char *fmt,va_list ap) { - va_list ap; - int n, size, off; + int n, size, off; while (1) { /* Try to print in the allocated space. */ - va_start(ap, fmt); size = sbuf->max_ - (sbuf->ptr_ - sbuf->buf_); n = vsnprintf (sbuf->ptr_, size, fmt, ap); - va_end(ap); /* If that worked, return the length. */ if (n > -1 && n < size) { sbuf->ptr_ += n; @@ -180,6 +177,19 @@ int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...) } } +// printf into a StringBuf, moving the pointer [MouseJstr] +int StringBuf_Printf(struct StringBuf *sbuf,const char *fmt,...) +{ + int len; + va_list ap; + + va_start(ap,fmt); + len = StringBuf_Vprintf(sbuf,fmt,ap); + va_end(ap); + + return len; +} + // Append buf2 onto the end of buf1 [MouseJstr] int StringBuf_Append(struct StringBuf *buf1,const struct StringBuf *buf2) { |