4 * Poor substitute for a real vsnprintf() function for systems
5 * that don't have them...
17 extern efunc nasm_malloc_error
;
19 #define BUFFER_SIZE 65536 /* Bigger than any string we might print... */
21 static char snprintf_buffer
[BUFFER_SIZE
];
23 int vsnprintf(char *str
, size_t size
, const char *format
, va_list ap
)
27 if (size
> BUFFER_SIZE
) {
28 nasm_malloc_error(ERR_PANIC
|ERR_NOFILE
,
29 "snprintf: size (%d) > BUFFER_SIZE (%d)",
34 rv
= vsprintf(snprintf_buffer
, format
, ap
);
35 if (rv
>= BUFFER_SIZE
) {
36 nasm_malloc_error(ERR_PANIC
|ERR_NOFILE
,
37 "snprintf buffer overflow");
41 if ((size_t)rv
< size
-1)
46 memcpy(str
, snprintf_buffer
, bytes
);