Browse Source

* 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
tags/json-c-0.10-20120530
Michael Clark 16 years ago
parent
commit
7fb9b03ffd
5 changed files with 12 additions and 10 deletions
  1. +2
    -0
      ChangeLog
  2. +1
    -1
      arraylist.c
  3. +4
    -4
      bits.h
  4. +4
    -4
      json_tokener.c
  5. +1
    -1
      printbuf.c

+ 2
- 0
ChangeLog View File

@@ -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.


+ 1
- 1
arraylist.c View 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*));


+ 4
- 4
bits.h View File

@@ -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)


+ 4
- 4
json_tokener.c View 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;


+ 1
- 1
printbuf.c View 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",


Loading…
Cancel
Save