rubber band in platform-specific code
[retroray] / libs / drawtext / draw.c
index 523239f..dec6101 100644 (file)
@@ -18,13 +18,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
-#if defined(WIN32) || defined(__WIN32__)
+#if defined(__WATCOMC__) || defined(_WIN32) || defined(__DJGPP__)
 #include <malloc.h>
 #else
 #include <alloca.h>
 #endif
 #include "drawtext.h"
-#include "drawtext_impl.h"
+#include "dtximpl.h"
 
 void dtx_position(float x, float y)
 {
@@ -83,31 +83,21 @@ void dtx_substring(const char *str, int start, int end)
        }
 }
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__WATCOMC__)
 #define vsnprintf _vsnprintf
 #endif
 
 void dtx_printf(const char *fmt, ...)
 {
        va_list ap;
-       int buf_size;
-       char *buf, tmp;
+       static char buf[1024];
 
        if(!dtx_font) {
                return;
        }
 
        va_start(ap, fmt);
-       buf_size = vsnprintf(&tmp, 0, fmt, ap);
-       va_end(ap);
-
-       if(buf_size == -1) {
-               buf_size = 512;
-       }
-
-       buf = alloca(buf_size + 1);
-       va_start(ap, fmt);
-       vsnprintf(buf, buf_size + 1, fmt, ap);
+       vsnprintf(buf, sizeof buf, fmt, ap);
        va_end(ap);
 
        dtx_string(buf);