aboutsummaryrefslogtreecommitdiff
path: root/redist
diff options
context:
space:
mode:
authormwturvey <michael.w.turvey@intel.com>2017-03-15 11:38:22 -0700
committermwturvey <michael.w.turvey@intel.com>2017-03-15 11:38:22 -0700
commit1caa844dad647b03cf3c1d11bf211e9fcde4b7f1 (patch)
tree5f5d7d8cb03b365390fc733f1eb677bb343725a1 /redist
parent8d4c581a6fb0c69883db7c1c5fe2820d53ccab13 (diff)
downloadlibsurvive-1caa844dad647b03cf3c1d11bf211e9fcde4b7f1.tar.gz
libsurvive-1caa844dad647b03cf3c1d11bf211e9fcde4b7f1.tar.bz2
Windows Compiling
Diffstat (limited to 'redist')
-rw-r--r--redist/json_helpers.c38
-rw-r--r--redist/os_generic.h2
2 files changed, 38 insertions, 2 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