From: Michael Clark Date: Sat, 25 Jul 2009 00:13:44 +0000 (+0000) Subject: * Rename min and max so we can never clash with C or C++ std library X-Git-Tag: json-c-0.10-20120530~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fb9b03ffdc5942c4e542b53f2bf96f4d36d3059;p=thirdparty%2Fjson-c.git * Rename min and max so we can never clash with C or C++ std library Ian Atha, thatha at yahoo-inc dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@43 327403b1-1117-474d-bef2-5cb71233fd97 --- diff --git a/ChangeLog b/ChangeLog index 6f956f0c..af71d9aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 0.9 + * Rename min and max so we can never clash with C or C++ std library + Ian Atha, thatha at yahoo-inc dot com * Fix any noticeable spelling or grammar errors. * Make sure every va_start has a va_end. * Check all pointers for validity. diff --git a/arraylist.c b/arraylist.c index 1d93f44b..cd04eea1 100644 --- a/arraylist.c +++ b/arraylist.c @@ -63,7 +63,7 @@ static int array_list_expand_internal(struct array_list *arr, int max) int new_size; if(max < arr->size) return 0; - new_size = max(arr->size << 1, max); + new_size = json_max(arr->size << 1, max); if(!(t = realloc(arr->array, new_size*sizeof(void*)))) return -1; arr->array = (void**)t; (void)memset(arr->array + arr->size, 0, (new_size-arr->size)*sizeof(void*)); diff --git a/bits.h b/bits.h index 2c107cce..f308da38 100644 --- a/bits.h +++ b/bits.h @@ -12,12 +12,12 @@ #ifndef _bits_h_ #define _bits_h_ -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) +#ifndef json_min +#define json_min(a,b) ((a) < (b) ? (a) : (b)) #endif -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) +#ifndef json_max +#define json_max(a,b) ((a) > (b) ? (a) : (b)) #endif #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) diff --git a/json_tokener.c b/json_tokener.c index 02facda0..04f11bac 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -119,7 +119,7 @@ char* strndup(const char* str, size_t n) { if(str) { size_t len = strlen(str); - size_t nn = min(len,n); + size_t nn = json_min(len,n); char* s = (char*)malloc(sizeof(char) * (nn + 1)); if(s) { @@ -276,7 +276,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_null: printbuf_memappend_fast(tok->pb, &c, 1); if(strncasecmp(json_null_str, tok->pb->buf, - min(tok->st_pos+1, strlen(json_null_str))) == 0) { + json_min(tok->st_pos+1, strlen(json_null_str))) == 0) { if(tok->st_pos == strlen(json_null_str)) { current = NULL; saved_state = json_tokener_state_finish; @@ -439,7 +439,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_boolean: printbuf_memappend_fast(tok->pb, &c, 1); if(strncasecmp(json_true_str, tok->pb->buf, - min(tok->st_pos+1, strlen(json_true_str))) == 0) { + json_min(tok->st_pos+1, strlen(json_true_str))) == 0) { if(tok->st_pos == strlen(json_true_str)) { current = json_object_new_boolean(1); saved_state = json_tokener_state_finish; @@ -447,7 +447,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, goto redo_char; } } else if(strncasecmp(json_false_str, tok->pb->buf, - min(tok->st_pos+1, strlen(json_false_str))) == 0) { + json_min(tok->st_pos+1, strlen(json_false_str))) == 0) { if(tok->st_pos == strlen(json_false_str)) { current = json_object_new_boolean(0); saved_state = json_tokener_state_finish; diff --git a/printbuf.c b/printbuf.c index a809aa9a..97366c39 100644 --- a/printbuf.c +++ b/printbuf.c @@ -49,7 +49,7 @@ int printbuf_memappend(struct printbuf *p, const char *buf, int size) { char *t; if(p->size - p->bpos <= size) { - int new_size = max(p->size * 2, p->bpos + size + 8); + int new_size = json_max(p->size * 2, p->bpos + size + 8); #ifdef PRINTBUF_DEBUG MC_DEBUG("printbuf_memappend: realloc " "bpos=%d wrsize=%d old_size=%d new_size=%d\n",