diff options
Diffstat (limited to 'redist')
-rw-r--r-- | redist/json_helpers.c | 38 | ||||
-rw-r--r-- | redist/os_generic.h | 2 | ||||
-rw-r--r-- | redist/symbol_enumerator.c | 2 |
3 files changed, 39 insertions, 3 deletions
diff --git a/redist/json_helpers.c b/redist/json_helpers.c index 4a3ba55..2413a67 100644 --- a/redist/json_helpers.c +++ b/redist/json_helpers.c @@ -7,7 +7,42 @@ #include <string.h> #include "json_helpers.h" #include <jsmn.h> +#include <malloc.h> +#ifdef _WIN32 +#include <stdarg.h> + +// Windows doesn't provide asprintf, so we need to make it. +int asprintf(char **strp, const char *fmt, ...) +{ + char* buff = NULL; + va_list listPointer; + va_start( listPointer, fmt ); + + size_t lenNeeded = _vscprintf(fmt, listPointer) + 1; // add one for a terminating null + + if (lenNeeded > 1) + { + buff = (char*)malloc(lenNeeded); + if (buff) + { + int bytesWritten = _vsnprintf(buff, lenNeeded, fmt, listPointer); + if (bytesWritten < 0) + { + free(buff); + buff = NULL; + } + } + } + + if (strp) + { + *strp = buff; + } + return (int)lenNeeded; +} + +#endif void json_write_float_array(FILE* f, const char* tag, float* v, uint8_t count) { uint8_t i = 0; @@ -101,7 +136,8 @@ static uint16_t json_load_array(const char* JSON_STRING, jsmntok_t* tokens, uint jsmntok_t* t = tokens; uint16_t i = 0; - char* values[size]; + char** values; + values = alloca(sizeof(char*) * size); for (i=0;i<size;++i) { t = tokens+i; diff --git a/redist/os_generic.h b/redist/os_generic.h index aac425b..0924030 100644 --- a/redist/os_generic.h +++ b/redist/os_generic.h @@ -1,7 +1,7 @@ #ifndef _OS_GENERIC_H
#define _OS_GENERIC_H
-#if defined( WIN32 ) || defined (WINDOWS)
+#if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32)
#define USE_WINDOWS
#endif
diff --git a/redist/symbol_enumerator.c b/redist/symbol_enumerator.c index eddddb9..7d33900 100644 --- a/redist/symbol_enumerator.c +++ b/redist/symbol_enumerator.c @@ -1,7 +1,7 @@ #include <stdio.h> #include "symbol_enumerator.h" -#if defined( WIN32 ) || defined( WINDOWS ) || defined( USE_WINDOWS ) +#if defined( WIN32 ) || defined( WINDOWS ) || defined( USE_WINDOWS ) || defined( _WIN32 ) #include <windows.h> |