OSDN Git Service

Extend features of tiling. (separation of Cell size and Tile size / add offset position.)
[hengband/hengband.git] / src / report.c
index 055ef50..9829bd7 100644 (file)
@@ -58,25 +58,6 @@ typedef struct {
 
 #define        BUFSIZE (65536)
 
-#ifndef HAVE_VASPRINTF
-#define vasprintf      Vasprintf
-
-static int Vasprintf(char **buf, const char *fmt, va_list ap)
-{
-       int ret;
-
-       *buf = malloc(1024);
-
-#if defined(HAVE_VSNPRINTF)
-       ret = vsnprintf(*buf, 1024, fmt, ap);
-#else
-       ret = vsprintf(*buf, fmt, ap);
-#endif
-       return ret;
-}
-
-#endif /* ifndef HAVE_VASPRINTF */ 
-
 static BUF* buf_new(void)
 {
        BUF *p;
@@ -123,14 +104,18 @@ static int buf_append(BUF *buf, const char *data, size_t size)
 static int buf_sprintf(BUF *buf, const char *fmt, ...)
 {
        int             ret;
-       char    *tmpbuf;
+       char    tmpbuf[8192];
        va_list ap;
 
        va_start(ap, fmt);
-       vasprintf(&tmpbuf, fmt, ap);
+#if defined(HAVE_VSNPRINTF)
+       ret = vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap);
+#else
+       ret = vsprintf(tmpbuf, fmt, ap);
+#endif
        va_end(ap);
 
-       if(!tmpbuf) return -1;
+       if (ret < 0) return -1;
 
 #if ('\r' == 0x0a && '\n' == 0x0d)
        {
@@ -154,8 +139,6 @@ static int buf_sprintf(BUF *buf, const char *fmt, ...)
 
        ret = buf_append(buf, tmpbuf, strlen(tmpbuf));
 
-       free(tmpbuf);
-
        return ret;
 }