Eliminate all uses of bits.h within the json-c code.
# include <strings.h>
#endif /* HAVE_STRINGS_H */
-#include "bits.h"
#include "arraylist.h"
struct array_list*
int new_size;
if(max < arr->size) return 0;
- new_size = json_max(arr->size << 1, max);
+ new_size = arr->size << 1;
+ if (new_size < max)
+ new_size = 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*));
-/*
+/**
+ * @file
+ * @deprecated Use json_util.h instead.
+ *
* $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
*
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
#ifndef _bits_h_
#define _bits_h_
-#ifndef json_min
-#define json_min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef json_max
-#define json_max(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
+/**
+ * @deprecated
+ */
#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
+/**
+ * @deprecated
+ */
#define error_ptr(error) ((void*)error)
+/**
+ * @deprecated
+ */
#define error_description(error) (json_tokener_get_error(error))
+/**
+ * @deprecated
+ */
#define is_error(ptr) (ptr == NULL)
#endif
extern "C" {
#endif
-#include "bits.h"
#include "debug.h"
#include "linkhash.h"
#include "arraylist.h"
#include <string.h>
#include <limits.h>
-#include "bits.h"
#include "debug.h"
#include "printbuf.h"
#include "arraylist.h"
#include <locale.h>
#endif /* HAVE_LOCALE_H */
+#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
+
#if !HAVE_STRDUP && defined(_MSC_VER)
/* MSC has the version as _strdup */
# define strdup _strdup
/* Handle a 4-byte sequence, or two sequences if a surrogate pair */
while(1) {
if(strchr(json_hex_chars, c)) {
- tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4));
+ tok->ucs_char += ((unsigned int)jt_hexdigit(c) << ((3-tok->st_pos++)*4));
if(tok->st_pos == 4) {
unsigned char unescaped_utf[4];
# error You do not have snprintf on your system.
#endif /* HAVE_SNPRINTF */
-#include "bits.h"
#include "debug.h"
#include "printbuf.h"
#include "json_inttypes.h"
#include "json_object.h"
+#ifndef json_min
+#define json_min(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef json_max
+#define json_max(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+
#ifdef __cplusplus
extern "C" {
#endif
# error Not enough var arg support!
#endif /* HAVE_STDARG_H */
-#include "bits.h"
#include "debug.h"
#include "printbuf.h"
if (p->size >= min_size)
return 0;
- new_size = json_max(p->size * 2, min_size + 8);
+ new_size = p->size * 2;
+ if (new_size < min_size + 8)
+ new_size = min_size + 8;
#ifdef PRINTBUF_DEBUG
MC_DEBUG("printbuf_memappend: realloc "
"bpos=%d min_size=%d old_size=%d new_size=%d\n",