]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
* Rename min and max so we can never clash with C or C++ std library
authorMichael Clark <michael@metaparadigm.com>
Sat, 25 Jul 2009 00:13:44 +0000 (00:13 +0000)
committerMichael Clark <michael@metaparadigm.com>
Sat, 25 Jul 2009 00:13:44 +0000 (00:13 +0000)
    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

ChangeLog
arraylist.c
bits.h
json_tokener.c
printbuf.c

index 6f956f0cf2425213e03ba04a1861be2ea0d92260..af71d9aae17939d9adca74f2553359ac367253f0 100644 (file)
--- 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.
index 1d93f44b4b3226d25a46a20826c33a0f7b376b3c..cd04eea1cc0acf611548e717c0af5fbda0ecab62 100644 (file)
@@ -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 2c107cce11a42fd1dd7821613e55dcb4666d1484..f308da3823a4865e2d6c2fa68974cf36cb0a9d79 100644 (file)
--- a/bits.h
+++ b/bits.h
 #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)
index 02facda0c8ba4931acdcd4f058742c35d66d4ff3..04f11bacbd7170ec6f2d2c976214e4bd41ecb214 100644 (file)
@@ -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;
index a809aa9afaa8ff624dd3e41c4c6f49baafc2db98..97366c39a021cca9e445c3830476976d66d4ba16 100644 (file)
@@ -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",