Skip to content
Snippets Groups Projects
Commit 53fa6004 authored by deuce's avatar deuce
Browse files

Add vasprintf() implementation called from asprintf(), and DLL-export them.

parent ff1a27c0
Branches
Tags
No related merge requests found
......@@ -45,25 +45,35 @@
#include "gen_defs.h"
#if defined(_MSC_VER) || defined(__MSVCRT__)
int asprintf(char **strptr, char *format, ...)
int DLLCALL vasprintf(char **strptr, char *format, va_list va)
{
va_list va;
va_list va2;
int ret;
if (strptr == NULL)
return -1;
va_start(va, format);
va_copy(va2, va);
ret = _vscprintf(format, va);
*strptr = (char *)malloc(ret+1);
if (*strptr == NULL)
return -1;
ret = vsprintf(*strptr, format, va2);
va_end(va);
va_end(va2);
return ret;
}
int DLLCALL asprintf(char **strptr, char *format, ...)
{
va_list va;
int ret;
if (strptr == NULL)
return -1;
va_start(va, format);
ret=vasprintf(strptr, format, va);
va_end(va);
return ret;
}
#endif
/* Maximum length of a format specifier including the % */
......
......@@ -79,6 +79,8 @@ DLLEXPORT char* DLLCALL xp_asprintf_end(char *format, size_t *endlen);
DLLEXPORT char* DLLCALL xp_asprintf(const char *format, ...);
DLLEXPORT char* DLLCALL xp_vasprintf(const char *format, va_list va);
DLLEXPORT int DLLCALL xp_printf_get_type(const char *format);
DLLEXPORT int DLLCALL vasprintf(char **strptr, char *format, va_list va);
DLLEXPORT int DLLCALL asprintf(char **strptr, char *format, ...);
#if defined(__cplusplus)
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment