From ea092618b1b6df81c09c6d3abb30516a7daa321e Mon Sep 17 00:00:00 2001 From: Tony Barbour Date: Mon, 13 Jul 2015 15:06:12 -0600 Subject: Windows: more fixes for windows compile --- loader/cJSON.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'loader/cJSON.c') diff --git a/loader/cJSON.c b/loader/cJSON.c index 2d55207b..2f56f850 100644 --- a/loader/cJSON.c +++ b/loader/cJSON.c @@ -114,13 +114,13 @@ static const char *parse_number(cJSON *item,const char *num) return num; } -static int pow2gt (int x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; } +static size_t pow2gt (size_t x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; } -typedef struct {char *buffer; int length; int offset; } printbuffer; +typedef struct {char *buffer; size_t length; size_t offset; } printbuffer; -static char* ensure(printbuffer *p,int needed) +static char* ensure(printbuffer *p,size_t needed) { - char *newbuffer;int newsize; + char *newbuffer;size_t newsize; if (!p || !p->buffer) return 0; needed+=p->offset; if (needed<=p->length) return p->buffer+p->offset; @@ -251,7 +251,7 @@ static const char *parse_string(cJSON *item,const char *str) /* Render the cstring provided to an escaped version that can be printed. */ static char *print_string_ptr(const char *str,printbuffer *p) { - const char *ptr;char *ptr2,*out;size_t len=0,flag=0;unsigned char token; + const char *ptr; char *ptr2; char *out; size_t len = 0, flag = 0; unsigned char token; for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0; if (!flag) @@ -434,10 +434,10 @@ static const char *parse_array(cJSON *item,const char *value) static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p) { char **entries; - char *out=0,*ptr,*ret;size_t len=5; - cJSON *child=item->child; - int numentries=0,i=0,fail=0; - size_t tmplen=0; + char *out=0,*ptr,*ret;size_t len=5; + cJSON *child=item->child; + int numentries=0,fail=0, j=0; + size_t tmplen=0,i=0; /* How many entries in the array? */ while (child) numentries++,child=child->next; @@ -490,7 +490,7 @@ static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p) /* Handle failure. */ if (fail) { - for (i=0;ichild; - int numentries=0,fail=0; - size_t tmplen=0; + int numentries=0,fail=0,k; + size_t tmplen=0,i=0,len=7; /* Count the number of entries. */ while (child) numentries++,child=child->next; /* Explicitly handle empty object case */ @@ -563,7 +563,7 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p) else out=(char*)cJSON_malloc(fmt?depth+4:3); if (!out) return 0; ptr=out;*ptr++='{'; - if (fmt) {*ptr++='\n';for (i=0;inext; } ptr=ensure(p,fmt?(depth+1):2); if (!ptr) return 0; - if (fmt) for (i=0;ibuffer)+i; } @@ -632,26 +632,26 @@ static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p) /* Handle failure */ if (fail) { - for (i=0;i