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.
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*));
#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)
{
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) {
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;
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;
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;
{
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",