* 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
This commit is contained in:
Michael Clark
2009-07-25 00:13:44 +00:00
parent b1a22ac85f
commit 7fb9b03ffd
5 changed files with 12 additions and 10 deletions

View File

@@ -1,4 +1,6 @@
0.9 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. * Fix any noticeable spelling or grammar errors.
* Make sure every va_start has a va_end. * Make sure every va_start has a va_end.
* Check all pointers for validity. * Check all pointers for validity.

View File

@@ -63,7 +63,7 @@ static int array_list_expand_internal(struct array_list *arr, int max)
int new_size; int new_size;
if(max < arr->size) return 0; 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; if(!(t = realloc(arr->array, new_size*sizeof(void*)))) return -1;
arr->array = (void**)t; arr->array = (void**)t;
(void)memset(arr->array + arr->size, 0, (new_size-arr->size)*sizeof(void*)); (void)memset(arr->array + arr->size, 0, (new_size-arr->size)*sizeof(void*));

8
bits.h
View File

@@ -12,12 +12,12 @@
#ifndef _bits_h_ #ifndef _bits_h_
#define _bits_h_ #define _bits_h_
#ifndef min #ifndef json_min
#define min(a,b) ((a) < (b) ? (a) : (b)) #define json_min(a,b) ((a) < (b) ? (a) : (b))
#endif #endif
#ifndef max #ifndef json_max
#define max(a,b) ((a) > (b) ? (a) : (b)) #define json_max(a,b) ((a) > (b) ? (a) : (b))
#endif #endif
#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)

View File

@@ -119,7 +119,7 @@ char* strndup(const char* str, size_t n)
{ {
if(str) { if(str) {
size_t len = strlen(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)); char* s = (char*)malloc(sizeof(char) * (nn + 1));
if(s) { if(s) {
@@ -276,7 +276,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
case json_tokener_state_null: case json_tokener_state_null:
printbuf_memappend_fast(tok->pb, &c, 1); printbuf_memappend_fast(tok->pb, &c, 1);
if(strncasecmp(json_null_str, tok->pb->buf, 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)) { if(tok->st_pos == strlen(json_null_str)) {
current = NULL; current = NULL;
saved_state = json_tokener_state_finish; 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: case json_tokener_state_boolean:
printbuf_memappend_fast(tok->pb, &c, 1); printbuf_memappend_fast(tok->pb, &c, 1);
if(strncasecmp(json_true_str, tok->pb->buf, 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)) { if(tok->st_pos == strlen(json_true_str)) {
current = json_object_new_boolean(1); current = json_object_new_boolean(1);
saved_state = json_tokener_state_finish; saved_state = json_tokener_state_finish;
@@ -447,7 +447,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
goto redo_char; goto redo_char;
} }
} else if(strncasecmp(json_false_str, tok->pb->buf, } 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)) { if(tok->st_pos == strlen(json_false_str)) {
current = json_object_new_boolean(0); current = json_object_new_boolean(0);
saved_state = json_tokener_state_finish; saved_state = json_tokener_state_finish;

View File

@@ -49,7 +49,7 @@ int printbuf_memappend(struct printbuf *p, const char *buf, int size)
{ {
char *t; char *t;
if(p->size - p->bpos <= size) { 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 #ifdef PRINTBUF_DEBUG
MC_DEBUG("printbuf_memappend: realloc " MC_DEBUG("printbuf_memappend: realloc "
"bpos=%d wrsize=%d old_size=%d new_size=%d\n", "bpos=%d wrsize=%d old_size=%d new_size=%d\n",