mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-09-19 18:47:54 +08:00
Provide vasprintf on Windows
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
// for ntohl
|
// for ntohl
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@@ -83,6 +83,24 @@ char *g_strconcat(const char *first, ...) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
int vasprintf(char **ret, const char *format, va_list ap) {
|
||||||
|
int len;
|
||||||
|
int retval;
|
||||||
|
char *result;
|
||||||
|
if ((len = _vscprintf(format, ap)) < 0)
|
||||||
|
return -1;
|
||||||
|
if ((result = malloc(len+1)) == NULL)
|
||||||
|
return -1;
|
||||||
|
if ((retval = _vsprintf_s(result, len+1, format, ap)) == -1) {
|
||||||
|
free(result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*ret = result;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *g_strdup_printf(const char *format, ...) {
|
char *g_strdup_printf(const char *format, ...) {
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
|
Reference in New Issue
Block a user