Przeglądaj źródła

Rename internal_hooks -> internal_configuration, cJSON_New_item -> create_item

Max Bruckner 7 lat temu
rodzic
commit
b277cd6a24

+ 88 - 88
cJSON.c

@@ -118,12 +118,12 @@ static int case_insensitive_strcmp(const unsigned char *string1, const unsigned
     return tolower(*string1) - tolower(*string2);
     return tolower(*string1) - tolower(*string2);
 }
 }
 
 
-typedef struct internal_hooks
+typedef struct internal_configuration
 {
 {
     void *(*allocate)(size_t size);
     void *(*allocate)(size_t size);
     void (*deallocate)(void *pointer);
     void (*deallocate)(void *pointer);
     void *(*reallocate)(void *pointer, size_t size);
     void *(*reallocate)(void *pointer, size_t size);
-} internal_hooks;
+} internal_configuration;
 
 
 #if defined(_MSC_VER)
 #if defined(_MSC_VER)
 /* work around MSVC error C2322: '...' address of dillimport '...' is not static */
 /* work around MSVC error C2322: '...' address of dillimport '...' is not static */
@@ -145,9 +145,9 @@ static void *internal_realloc(void *pointer, size_t size)
 #define internal_realloc realloc
 #define internal_realloc realloc
 #endif
 #endif
 
 
-static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
+static internal_configuration global_configuration = { internal_malloc, internal_free, internal_realloc };
 
 
-static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
+static unsigned char* custom_strdup(const unsigned char* string, const internal_configuration * const configuration)
 {
 {
     size_t length = 0;
     size_t length = 0;
     unsigned char *copy = NULL;
     unsigned char *copy = NULL;
@@ -158,7 +158,7 @@ static unsigned char* cJSON_strdup(const unsigned char* string, const internal_h
     }
     }
 
 
     length = strlen((const char*)string) + sizeof("");
     length = strlen((const char*)string) + sizeof("");
-    copy = (unsigned char*)hooks->allocate(length);
+    copy = (unsigned char*)configuration->allocate(length);
     if (copy == NULL)
     if (copy == NULL)
     {
     {
         return NULL;
         return NULL;
@@ -173,36 +173,36 @@ CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
     if (hooks == NULL)
     if (hooks == NULL)
     {
     {
         /* Reset hooks */
         /* Reset hooks */
-        global_hooks.allocate = malloc;
-        global_hooks.deallocate = free;
-        global_hooks.reallocate = realloc;
+        global_configuration.allocate = malloc;
+        global_configuration.deallocate = free;
+        global_configuration.reallocate = realloc;
         return;
         return;
     }
     }
 
 
-    global_hooks.allocate = malloc;
+    global_configuration.allocate = malloc;
     if (hooks->malloc_fn != NULL)
     if (hooks->malloc_fn != NULL)
     {
     {
-        global_hooks.allocate = hooks->malloc_fn;
+        global_configuration.allocate = hooks->malloc_fn;
     }
     }
 
 
-    global_hooks.deallocate = free;
+    global_configuration.deallocate = free;
     if (hooks->free_fn != NULL)
     if (hooks->free_fn != NULL)
     {
     {
-        global_hooks.deallocate = hooks->free_fn;
+        global_configuration.deallocate = hooks->free_fn;
     }
     }
 
 
     /* use realloc only if both free and malloc are used */
     /* use realloc only if both free and malloc are used */
-    global_hooks.reallocate = NULL;
-    if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
+    global_configuration.reallocate = NULL;
+    if ((global_configuration.allocate == malloc) && (global_configuration.deallocate == free))
     {
     {
-        global_hooks.reallocate = realloc;
+        global_configuration.reallocate = realloc;
     }
     }
 }
 }
 
 
 /* Internal constructor. */
 /* Internal constructor. */
-static cJSON *cJSON_New_Item(const internal_hooks * const hooks)
+static cJSON *create_item(const internal_configuration * const configuration)
 {
 {
-    cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON));
+    cJSON* node = (cJSON*)configuration->allocate(sizeof(cJSON));
     if (node)
     if (node)
     {
     {
         memset(node, '\0', sizeof(cJSON));
         memset(node, '\0', sizeof(cJSON));
@@ -224,13 +224,13 @@ CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
         }
         }
         if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
         if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
         {
         {
-            global_hooks.deallocate(item->valuestring);
+            global_configuration.deallocate(item->valuestring);
         }
         }
         if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
         if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
         {
         {
-            global_hooks.deallocate(item->string);
+            global_configuration.deallocate(item->string);
         }
         }
-        global_hooks.deallocate(item);
+        global_configuration.deallocate(item);
         item = next;
         item = next;
     }
     }
 }
 }
@@ -266,7 +266,7 @@ typedef struct
     size_t length;
     size_t length;
     size_t offset;
     size_t offset;
     size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */
     size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */
-    internal_hooks hooks;
+    internal_configuration configuration;
 } parse_buffer;
 } parse_buffer;
 
 
 /* check if the given size is left to read in a given parse buffer (starting with 1) */
 /* check if the given size is left to read in a given parse buffer (starting with 1) */
@@ -356,7 +356,7 @@ typedef struct
     size_t depth; /* current nesting depth (for formatted printing) */
     size_t depth; /* current nesting depth (for formatted printing) */
     cJSON_bool noalloc;
     cJSON_bool noalloc;
     cJSON_bool format; /* is this print a formatted print */
     cJSON_bool format; /* is this print a formatted print */
-    internal_hooks hooks;
+    internal_configuration configuration;
 } printbuffer;
 } printbuffer;
 
 
 /* realloc printbuffer if necessary to have at least "needed" bytes more */
 /* realloc printbuffer if necessary to have at least "needed" bytes more */
@@ -410,13 +410,13 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
         newsize = needed * 2;
         newsize = needed * 2;
     }
     }
 
 
-    if (p->hooks.reallocate != NULL)
+    if (p->configuration.reallocate != NULL)
     {
     {
         /* reallocate with realloc if available */
         /* reallocate with realloc if available */
-        newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize);
+        newbuffer = (unsigned char*)p->configuration.reallocate(p->buffer, newsize);
         if (newbuffer == NULL)
         if (newbuffer == NULL)
         {
         {
-            p->hooks.deallocate(p->buffer);
+            p->configuration.deallocate(p->buffer);
             p->length = 0;
             p->length = 0;
             p->buffer = NULL;
             p->buffer = NULL;
 
 
@@ -426,10 +426,10 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
     else
     else
     {
     {
         /* otherwise reallocate manually */
         /* otherwise reallocate manually */
-        newbuffer = (unsigned char*)p->hooks.allocate(newsize);
+        newbuffer = (unsigned char*)p->configuration.allocate(newsize);
         if (!newbuffer)
         if (!newbuffer)
         {
         {
-            p->hooks.deallocate(p->buffer);
+            p->configuration.deallocate(p->buffer);
             p->length = 0;
             p->length = 0;
             p->buffer = NULL;
             p->buffer = NULL;
 
 
@@ -439,7 +439,7 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
         {
         {
             memcpy(newbuffer, p->buffer, p->offset + 1);
             memcpy(newbuffer, p->buffer, p->offset + 1);
         }
         }
-        p->hooks.deallocate(p->buffer);
+        p->configuration.deallocate(p->buffer);
     }
     }
     p->length = newsize;
     p->length = newsize;
     p->buffer = newbuffer;
     p->buffer = newbuffer;
@@ -731,7 +731,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
 
 
         /* This is at most how much we need for the output */
         /* This is at most how much we need for the output */
         allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
         allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
-        output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof(""));
+        output = (unsigned char*)input_buffer->configuration.allocate(allocation_length + sizeof(""));
         if (output == NULL)
         if (output == NULL)
         {
         {
             goto fail; /* allocation failure */
             goto fail; /* allocation failure */
@@ -809,7 +809,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
 fail:
 fail:
     if (output != NULL)
     if (output != NULL)
     {
     {
-        input_buffer->hooks.deallocate(output);
+        input_buffer->configuration.deallocate(output);
     }
     }
 
 
     if (input_pointer != NULL)
     if (input_pointer != NULL)
@@ -1011,9 +1011,9 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return
     buffer.content = (const unsigned char*)value;
     buffer.content = (const unsigned char*)value;
     buffer.length = strlen((const char*)value) + sizeof("");
     buffer.length = strlen((const char*)value) + sizeof("");
     buffer.offset = 0;
     buffer.offset = 0;
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
-    item = cJSON_New_Item(&global_hooks);
+    item = create_item(&global_configuration);
     if (item == NULL) /* memory fail */
     if (item == NULL) /* memory fail */
     {
     {
         goto fail;
         goto fail;
@@ -1081,7 +1081,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
 
 
 #define cjson_min(a, b) ((a < b) ? a : b)
 #define cjson_min(a, b) ((a < b) ? a : b)
 
 
-static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
+static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_configuration * const configuration)
 {
 {
     static const size_t default_buffer_size = 256;
     static const size_t default_buffer_size = 256;
     printbuffer buffer[1];
     printbuffer buffer[1];
@@ -1090,10 +1090,10 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
     memset(buffer, 0, sizeof(buffer));
     memset(buffer, 0, sizeof(buffer));
 
 
     /* create buffer */
     /* create buffer */
-    buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
+    buffer->buffer = (unsigned char*) configuration->allocate(default_buffer_size);
     buffer->length = default_buffer_size;
     buffer->length = default_buffer_size;
     buffer->format = format;
     buffer->format = format;
-    buffer->hooks = *hooks;
+    buffer->configuration = *configuration;
     if (buffer->buffer == NULL)
     if (buffer->buffer == NULL)
     {
     {
         goto fail;
         goto fail;
@@ -1109,9 +1109,9 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
     /* Reallocate the buffer so that it only uses as much as it needs.
     /* Reallocate the buffer so that it only uses as much as it needs.
         This can save up to 50% because ensure increases the buffer size by a factor of 2 */
         This can save up to 50% because ensure increases the buffer size by a factor of 2 */
     /* check if reallocate is available */
     /* check if reallocate is available */
-    if (hooks->reallocate != NULL)
+    if (configuration->reallocate != NULL)
     {
     {
-        printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
+        printed = (unsigned char*) configuration->reallocate(buffer->buffer, buffer->offset + 1);
         buffer->buffer = NULL;
         buffer->buffer = NULL;
         if (printed == NULL) {
         if (printed == NULL) {
             goto fail;
             goto fail;
@@ -1119,7 +1119,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
     }
     }
     else /* otherwise copy the JSON over to a new buffer */
     else /* otherwise copy the JSON over to a new buffer */
     {
     {
-        printed = (unsigned char*) hooks->allocate(buffer->offset + 1);
+        printed = (unsigned char*) configuration->allocate(buffer->offset + 1);
         if (printed == NULL)
         if (printed == NULL)
         {
         {
             goto fail;
             goto fail;
@@ -1128,7 +1128,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
         printed[buffer->offset] = '\0'; /* just to be sure */
         printed[buffer->offset] = '\0'; /* just to be sure */
 
 
         /* free the buffer */
         /* free the buffer */
-        hooks->deallocate(buffer->buffer);
+        configuration->deallocate(buffer->buffer);
     }
     }
 
 
     return printed;
     return printed;
@@ -1136,12 +1136,12 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
 fail:
 fail:
     if (buffer->buffer != NULL)
     if (buffer->buffer != NULL)
     {
     {
-        hooks->deallocate(buffer->buffer);
+        configuration->deallocate(buffer->buffer);
     }
     }
 
 
     if (printed != NULL)
     if (printed != NULL)
     {
     {
-        hooks->deallocate(printed);
+        configuration->deallocate(printed);
     }
     }
 
 
     return NULL;
     return NULL;
@@ -1150,12 +1150,12 @@ fail:
 /* Render a cJSON item/entity/structure to text. */
 /* Render a cJSON item/entity/structure to text. */
 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
 {
 {
-    return (char*)print(item, true, &global_hooks);
+    return (char*)print(item, true, &global_configuration);
 }
 }
 
 
 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
 CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item)
 {
 {
-    return (char*)print(item, false, &global_hooks);
+    return (char*)print(item, false, &global_configuration);
 }
 }
 
 
 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
 CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
@@ -1167,7 +1167,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
         return NULL;
         return NULL;
     }
     }
 
 
-    p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
+    p.buffer = (unsigned char*)global_configuration.allocate((size_t)prebuffer);
     if (!p.buffer)
     if (!p.buffer)
     {
     {
         return NULL;
         return NULL;
@@ -1177,11 +1177,11 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
     p.offset = 0;
     p.offset = 0;
     p.noalloc = false;
     p.noalloc = false;
     p.format = fmt;
     p.format = fmt;
-    p.hooks = global_hooks;
+    p.configuration = global_configuration;
 
 
     if (!print_value(item, &p))
     if (!print_value(item, &p))
     {
     {
-        global_hooks.deallocate(p.buffer);
+        global_configuration.deallocate(p.buffer);
         return NULL;
         return NULL;
     }
     }
 
 
@@ -1202,7 +1202,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, cons
     p.offset = 0;
     p.offset = 0;
     p.noalloc = true;
     p.noalloc = true;
     p.format = format;
     p.format = format;
-    p.hooks = global_hooks;
+    p.configuration = global_configuration;
 
 
     return print_value(item, &p);
     return print_value(item, &p);
 }
 }
@@ -1335,7 +1335,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp
             {
             {
                 if (!output_buffer->noalloc)
                 if (!output_buffer->noalloc)
                 {
                 {
-                    output_buffer->hooks.deallocate(output_buffer->buffer);
+                    output_buffer->configuration.deallocate(output_buffer->buffer);
                 }
                 }
                 return false;
                 return false;
             }
             }
@@ -1403,7 +1403,7 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
     do
     do
     {
     {
         /* allocate next item */
         /* allocate next item */
-        cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
+        cJSON *new_item = create_item(&(input_buffer->configuration));
         if (new_item == NULL)
         if (new_item == NULL)
         {
         {
             goto fail; /* allocation failure */
             goto fail; /* allocation failure */
@@ -1557,7 +1557,7 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
     do
     do
     {
     {
         /* allocate next item */
         /* allocate next item */
-        cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
+        cJSON *new_item = create_item(&(input_buffer->configuration));
         if (new_item == NULL)
         if (new_item == NULL)
         {
         {
             goto fail; /* allocation failure */
             goto fail; /* allocation failure */
@@ -1858,7 +1858,7 @@ static void suffix_object(cJSON *prev, cJSON *item)
 }
 }
 
 
 /* Utility for handling references. */
 /* Utility for handling references. */
-static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks)
+static cJSON *create_reference(const cJSON *item, const internal_configuration * const configuration)
 {
 {
     cJSON *reference = NULL;
     cJSON *reference = NULL;
     if (item == NULL)
     if (item == NULL)
@@ -1866,7 +1866,7 @@ static cJSON *create_reference(const cJSON *item, const internal_hooks * const h
         return NULL;
         return NULL;
     }
     }
 
 
-    reference = cJSON_New_Item(hooks);
+    reference = create_item(configuration);
     if (reference == NULL)
     if (reference == NULL)
     {
     {
         return NULL;
         return NULL;
@@ -1930,7 +1930,7 @@ static void* cast_away_const(const void* string)
 #endif
 #endif
 
 
 
 
-static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key)
+static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_configuration * const configuration, const cJSON_bool constant_key)
 {
 {
     if ((object == NULL) || (string == NULL) || (item == NULL))
     if ((object == NULL) || (string == NULL) || (item == NULL))
     {
     {
@@ -1939,7 +1939,7 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
 
 
     if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
     if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
     {
     {
-        hooks->deallocate(item->string);
+        configuration->deallocate(item->string);
     }
     }
 
 
     if (constant_key)
     if (constant_key)
@@ -1949,7 +1949,7 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
     }
     }
     else
     else
     {
     {
-        char *key = (char*)cJSON_strdup((const unsigned char*)string, hooks);
+        char *key = (char*)custom_strdup((const unsigned char*)string, configuration);
         if (key == NULL)
         if (key == NULL)
         {
         {
             return false;
             return false;
@@ -1964,13 +1964,13 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st
 
 
 CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
 CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
 {
 {
-    add_item_to_object(object, string, item, &global_hooks, false);
+    add_item_to_object(object, string, item, &global_configuration, false);
 }
 }
 
 
 /* Add an item to an object with constant string as key */
 /* Add an item to an object with constant string as key */
 CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
 CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
 {
 {
-    add_item_to_object(object, string, item, &global_hooks, true);
+    add_item_to_object(object, string, item, &global_configuration, true);
 }
 }
 
 
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
@@ -1980,7 +1980,7 @@ CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
         return;
         return;
     }
     }
 
 
-    add_item_to_array(array, create_reference(item, &global_hooks));
+    add_item_to_array(array, create_reference(item, &global_configuration));
 }
 }
 
 
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
 CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item)
@@ -1990,13 +1990,13 @@ CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *str
         return;
         return;
     }
     }
 
 
-    add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false);
+    add_item_to_object(object, string, create_reference(item, &global_configuration), &global_configuration, false);
 }
 }
 
 
 CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
 CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name)
 {
 {
     cJSON *null = cJSON_CreateNull();
     cJSON *null = cJSON_CreateNull();
-    if (add_item_to_object(object, name, null, &global_hooks, false))
+    if (add_item_to_object(object, name, null, &global_configuration, false))
     {
     {
         return null;
         return null;
     }
     }
@@ -2008,7 +2008,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * co
 CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name)
 CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name)
 {
 {
     cJSON *true_item = cJSON_CreateTrue();
     cJSON *true_item = cJSON_CreateTrue();
-    if (add_item_to_object(object, name, true_item, &global_hooks, false))
+    if (add_item_to_object(object, name, true_item, &global_configuration, false))
     {
     {
         return true_item;
         return true_item;
     }
     }
@@ -2020,7 +2020,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * co
 CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name)
 CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name)
 {
 {
     cJSON *false_item = cJSON_CreateFalse();
     cJSON *false_item = cJSON_CreateFalse();
-    if (add_item_to_object(object, name, false_item, &global_hooks, false))
+    if (add_item_to_object(object, name, false_item, &global_configuration, false))
     {
     {
         return false_item;
         return false_item;
     }
     }
@@ -2032,7 +2032,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * c
 CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean)
 CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean)
 {
 {
     cJSON *bool_item = cJSON_CreateBool(boolean);
     cJSON *bool_item = cJSON_CreateBool(boolean);
-    if (add_item_to_object(object, name, bool_item, &global_hooks, false))
+    if (add_item_to_object(object, name, bool_item, &global_configuration, false))
     {
     {
         return bool_item;
         return bool_item;
     }
     }
@@ -2044,7 +2044,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * co
 CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number)
 CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number)
 {
 {
     cJSON *number_item = cJSON_CreateNumber(number);
     cJSON *number_item = cJSON_CreateNumber(number);
-    if (add_item_to_object(object, name, number_item, &global_hooks, false))
+    if (add_item_to_object(object, name, number_item, &global_configuration, false))
     {
     {
         return number_item;
         return number_item;
     }
     }
@@ -2056,7 +2056,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char *
 CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
 CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
 {
 {
     cJSON *string_item = cJSON_CreateString(string);
     cJSON *string_item = cJSON_CreateString(string);
-    if (add_item_to_object(object, name, string_item, &global_hooks, false))
+    if (add_item_to_object(object, name, string_item, &global_configuration, false))
     {
     {
         return string_item;
         return string_item;
     }
     }
@@ -2068,7 +2068,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char *
 CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw)
 CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw)
 {
 {
     cJSON *raw_item = cJSON_CreateRaw(raw);
     cJSON *raw_item = cJSON_CreateRaw(raw);
-    if (add_item_to_object(object, name, raw_item, &global_hooks, false))
+    if (add_item_to_object(object, name, raw_item, &global_configuration, false))
     {
     {
         return raw_item;
         return raw_item;
     }
     }
@@ -2080,7 +2080,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * con
 CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name)
 CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name)
 {
 {
     cJSON *object_item = cJSON_CreateObject();
     cJSON *object_item = cJSON_CreateObject();
-    if (add_item_to_object(object, name, object_item, &global_hooks, false))
+    if (add_item_to_object(object, name, object_item, &global_configuration, false))
     {
     {
         return object_item;
         return object_item;
     }
     }
@@ -2092,7 +2092,7 @@ CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char *
 CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
 CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
 {
 {
     cJSON *array = cJSON_CreateArray();
     cJSON *array = cJSON_CreateArray();
-    if (add_item_to_object(object, name, array, &global_hooks, false))
+    if (add_item_to_object(object, name, array, &global_configuration, false))
     {
     {
         return array;
         return array;
     }
     }
@@ -2257,7 +2257,7 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO
     {
     {
         cJSON_free(replacement->string);
         cJSON_free(replacement->string);
     }
     }
-    replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
+    replacement->string = (char*)custom_strdup((const unsigned char*)string, &global_configuration);
     replacement->type &= ~cJSON_StringIsConst;
     replacement->type &= ~cJSON_StringIsConst;
 
 
     cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
     cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
@@ -2278,7 +2278,7 @@ CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const c
 /* Create basic types: */
 /* Create basic types: */
 CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
 CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_NULL;
         item->type = cJSON_NULL;
@@ -2289,7 +2289,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
 CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_True;
         item->type = cJSON_True;
@@ -2300,7 +2300,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
 CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_False;
         item->type = cJSON_False;
@@ -2311,7 +2311,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
 CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = boolean ? cJSON_True : cJSON_False;
         item->type = boolean ? cJSON_True : cJSON_False;
@@ -2322,7 +2322,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
 CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_Number;
         item->type = cJSON_Number;
@@ -2335,11 +2335,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
 CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_String;
         item->type = cJSON_String;
-        item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
+        item->valuestring = (char*)custom_strdup((const unsigned char*)string, &global_configuration);
         if(!item->valuestring)
         if(!item->valuestring)
         {
         {
             cJSON_Delete(item);
             cJSON_Delete(item);
@@ -2352,7 +2352,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
 CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if (item != NULL)
     if (item != NULL)
     {
     {
         item->type = cJSON_String | cJSON_IsReference;
         item->type = cJSON_String | cJSON_IsReference;
@@ -2364,7 +2364,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
 CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if (item != NULL) {
     if (item != NULL) {
         item->type = cJSON_Object | cJSON_IsReference;
         item->type = cJSON_Object | cJSON_IsReference;
         item->child = (cJSON*)cast_away_const(child);
         item->child = (cJSON*)cast_away_const(child);
@@ -2374,7 +2374,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child)
 }
 }
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
 CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if (item != NULL) {
     if (item != NULL) {
         item->type = cJSON_Array | cJSON_IsReference;
         item->type = cJSON_Array | cJSON_IsReference;
         item->child = (cJSON*)cast_away_const(child);
         item->child = (cJSON*)cast_away_const(child);
@@ -2385,11 +2385,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
 CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type = cJSON_Raw;
         item->type = cJSON_Raw;
-        item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks);
+        item->valuestring = (char*)custom_strdup((const unsigned char*)raw, &global_configuration);
         if(!item->valuestring)
         if(!item->valuestring)
         {
         {
             cJSON_Delete(item);
             cJSON_Delete(item);
@@ -2402,7 +2402,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
 CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if(item)
     if(item)
     {
     {
         item->type=cJSON_Array;
         item->type=cJSON_Array;
@@ -2413,7 +2413,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
 
 
 CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
 CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
 {
 {
-    cJSON *item = cJSON_New_Item(&global_hooks);
+    cJSON *item = create_item(&global_configuration);
     if (item)
     if (item)
     {
     {
         item->type = cJSON_Object;
         item->type = cJSON_Object;
@@ -2580,7 +2580,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
         goto fail;
         goto fail;
     }
     }
     /* Create new item */
     /* Create new item */
-    newitem = cJSON_New_Item(&global_hooks);
+    newitem = create_item(&global_configuration);
     if (!newitem)
     if (!newitem)
     {
     {
         goto fail;
         goto fail;
@@ -2591,7 +2591,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
     newitem->valuedouble = item->valuedouble;
     newitem->valuedouble = item->valuedouble;
     if (item->valuestring)
     if (item->valuestring)
     {
     {
-        newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks);
+        newitem->valuestring = (char*)custom_strdup((unsigned char*)item->valuestring, &global_configuration);
         if (!newitem->valuestring)
         if (!newitem->valuestring)
         {
         {
             goto fail;
             goto fail;
@@ -2599,7 +2599,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
     }
     }
     if (item->string)
     if (item->string)
     {
     {
-        newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks);
+        newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)custom_strdup((unsigned char*)item->string, &global_configuration);
         if (!newitem->string)
         if (!newitem->string)
         {
         {
             goto fail;
             goto fail;
@@ -2935,10 +2935,10 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
 
 
 CJSON_PUBLIC(void *) cJSON_malloc(size_t size)
 CJSON_PUBLIC(void *) cJSON_malloc(size_t size)
 {
 {
-    return global_hooks.allocate(size);
+    return global_configuration.allocate(size);
 }
 }
 
 
 CJSON_PUBLIC(void) cJSON_free(void *object)
 CJSON_PUBLIC(void) cJSON_free(void *object)
 {
 {
-    global_hooks.deallocate(object);
+    global_configuration.deallocate(object);
 }
 }

+ 2 - 2
tests/common.h

@@ -33,11 +33,11 @@ void reset(cJSON *item) {
     }
     }
     if ((item->valuestring != NULL) && !(item->type & cJSON_IsReference))
     if ((item->valuestring != NULL) && !(item->type & cJSON_IsReference))
     {
     {
-        global_hooks.deallocate(item->valuestring);
+        global_configuration.deallocate(item->valuestring);
     }
     }
     if ((item->string != NULL) && !(item->type & cJSON_StringIsConst))
     if ((item->string != NULL) && !(item->type & cJSON_StringIsConst))
     {
     {
-        global_hooks.deallocate(item->string);
+        global_configuration.deallocate(item->string);
     }
     }
 
 
     memset(item, 0, sizeof(cJSON));
     memset(item, 0, sizeof(cJSON));

+ 2 - 2
tests/misc_tests.c

@@ -432,7 +432,7 @@ static void skip_utf8_bom_should_skip_bom(void)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = string;
     buffer.content = string;
     buffer.length = sizeof(string);
     buffer.length = sizeof(string);
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE(skip_utf8_bom(&buffer) == &buffer);
     TEST_ASSERT_TRUE(skip_utf8_bom(&buffer) == &buffer);
     TEST_ASSERT_EQUAL_UINT(3U, (unsigned int)buffer.offset);
     TEST_ASSERT_EQUAL_UINT(3U, (unsigned int)buffer.offset);
@@ -444,7 +444,7 @@ static void skip_utf8_bom_should_not_skip_bom_if_not_at_beginning(void)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = string;
     buffer.content = string;
     buffer.length = sizeof(string);
     buffer.length = sizeof(string);
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
     buffer.offset = 1;
     buffer.offset = 1;
 
 
     TEST_ASSERT_NULL(skip_utf8_bom(&buffer));
     TEST_ASSERT_NULL(skip_utf8_bom(&buffer));

+ 2 - 2
tests/parse_array.c

@@ -47,7 +47,7 @@ static void assert_not_array(const char *json)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = (const unsigned char*)json;
     buffer.content = (const unsigned char*)json;
     buffer.length = strlen(json) + sizeof("");
     buffer.length = strlen(json) + sizeof("");
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_FALSE(parse_array(item, &buffer));
     TEST_ASSERT_FALSE(parse_array(item, &buffer));
     assert_is_invalid(item);
     assert_is_invalid(item);
@@ -58,7 +58,7 @@ static void assert_parse_array(const char *json)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = (const unsigned char*)json;
     buffer.content = (const unsigned char*)json;
     buffer.length = strlen(json) + sizeof("");
     buffer.length = strlen(json) + sizeof("");
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE(parse_array(item, &buffer));
     TEST_ASSERT_TRUE(parse_array(item, &buffer));
     assert_is_array(item);
     assert_is_array(item);

+ 2 - 2
tests/parse_object.c

@@ -55,7 +55,7 @@ static void assert_not_object(const char *json)
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parsebuffer.content = (const unsigned char*)json;
     parsebuffer.content = (const unsigned char*)json;
     parsebuffer.length = strlen(json) + sizeof("");
     parsebuffer.length = strlen(json) + sizeof("");
-    parsebuffer.hooks = global_hooks;
+    parsebuffer.configuration = global_configuration;
 
 
     TEST_ASSERT_FALSE(parse_object(item, &parsebuffer));
     TEST_ASSERT_FALSE(parse_object(item, &parsebuffer));
     assert_is_invalid(item);
     assert_is_invalid(item);
@@ -67,7 +67,7 @@ static void assert_parse_object(const char *json)
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parsebuffer.content = (const unsigned char*)json;
     parsebuffer.content = (const unsigned char*)json;
     parsebuffer.length = strlen(json) + sizeof("");
     parsebuffer.length = strlen(json) + sizeof("");
-    parsebuffer.hooks = global_hooks;
+    parsebuffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE(parse_object(item, &parsebuffer));
     TEST_ASSERT_TRUE(parse_object(item, &parsebuffer));
     assert_is_object(item);
     assert_is_object(item);

+ 3 - 3
tests/parse_string.c

@@ -48,12 +48,12 @@ static void assert_parse_string(const char *string, const char *expected)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = (const unsigned char*)string;
     buffer.content = (const unsigned char*)string;
     buffer.length = strlen(string) + sizeof("");
     buffer.length = strlen(string) + sizeof("");
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE_MESSAGE(parse_string(item, &buffer), "Couldn't parse string.");
     TEST_ASSERT_TRUE_MESSAGE(parse_string(item, &buffer), "Couldn't parse string.");
     assert_is_string(item);
     assert_is_string(item);
     TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, item->valuestring, "The parsed result isn't as expected.");
     TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, item->valuestring, "The parsed result isn't as expected.");
-    global_hooks.deallocate(item->valuestring);
+    global_configuration.deallocate(item->valuestring);
     item->valuestring = NULL;
     item->valuestring = NULL;
 }
 }
 
 
@@ -62,7 +62,7 @@ static void assert_not_parse_string(const char * const string)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = (const unsigned char*)string;
     buffer.content = (const unsigned char*)string;
     buffer.length = strlen(string) + sizeof("");
     buffer.length = strlen(string) + sizeof("");
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_FALSE_MESSAGE(parse_string(item, &buffer), "Malformed string should not be accepted.");
     TEST_ASSERT_FALSE_MESSAGE(parse_string(item, &buffer), "Malformed string should not be accepted.");
     assert_is_invalid(item);
     assert_is_invalid(item);

+ 1 - 1
tests/parse_value.c

@@ -46,7 +46,7 @@ static void assert_parse_value(const char *string, int type)
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     buffer.content = (const unsigned char*) string;
     buffer.content = (const unsigned char*) string;
     buffer.length = strlen(string) + sizeof("");
     buffer.length = strlen(string) + sizeof("");
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE(parse_value(item, &buffer));
     TEST_ASSERT_TRUE(parse_value(item, &buffer));
     assert_is_value(item, type);
     assert_is_value(item, type);

+ 3 - 3
tests/print_array.c

@@ -37,21 +37,21 @@ static void assert_print_array(const char * const expected, const char * const i
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parse_buffer parsebuffer = { 0, 0, 0, 0, { 0, 0, 0 } };
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.length = strlen(input) + sizeof("");
     parsebuffer.length = strlen(input) + sizeof("");
-    parsebuffer.hooks = global_hooks;
+    parsebuffer.configuration = global_configuration;
 
 
     /* buffer for formatted printing */
     /* buffer for formatted printing */
     formatted_buffer.buffer = printed_formatted;
     formatted_buffer.buffer = printed_formatted;
     formatted_buffer.length = sizeof(printed_formatted);
     formatted_buffer.length = sizeof(printed_formatted);
     formatted_buffer.offset = 0;
     formatted_buffer.offset = 0;
     formatted_buffer.noalloc = true;
     formatted_buffer.noalloc = true;
-    formatted_buffer.hooks = global_hooks;
+    formatted_buffer.configuration = global_configuration;
 
 
     /* buffer for unformatted printing */
     /* buffer for unformatted printing */
     unformatted_buffer.buffer = printed_unformatted;
     unformatted_buffer.buffer = printed_unformatted;
     unformatted_buffer.length = sizeof(printed_unformatted);
     unformatted_buffer.length = sizeof(printed_unformatted);
     unformatted_buffer.offset = 0;
     unformatted_buffer.offset = 0;
     unformatted_buffer.noalloc = true;
     unformatted_buffer.noalloc = true;
-    unformatted_buffer.hooks = global_hooks;
+    unformatted_buffer.configuration = global_configuration;
 
 
     memset(item, 0, sizeof(item));
     memset(item, 0, sizeof(item));
     TEST_ASSERT_TRUE_MESSAGE(parse_array(item, &parsebuffer), "Failed to parse array.");
     TEST_ASSERT_TRUE_MESSAGE(parse_array(item, &parsebuffer), "Failed to parse array.");

+ 1 - 1
tests/print_number.c

@@ -33,7 +33,7 @@ static void assert_print_number(const char *expected, double input)
     buffer.length = sizeof(printed);
     buffer.length = sizeof(printed);
     buffer.offset = 0;
     buffer.offset = 0;
     buffer.noalloc = true;
     buffer.noalloc = true;
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     memset(item, 0, sizeof(item));
     memset(item, 0, sizeof(item));
     cJSON_SetNumberValue(item, input);
     cJSON_SetNumberValue(item, input);

+ 3 - 3
tests/print_object.c

@@ -38,21 +38,21 @@ static void assert_print_object(const char * const expected, const char * const
     /* buffer for parsing */
     /* buffer for parsing */
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.length = strlen(input) + sizeof("");
     parsebuffer.length = strlen(input) + sizeof("");
-    parsebuffer.hooks = global_hooks;
+    parsebuffer.configuration = global_configuration;
 
 
     /* buffer for formatted printing */
     /* buffer for formatted printing */
     formatted_buffer.buffer = printed_formatted;
     formatted_buffer.buffer = printed_formatted;
     formatted_buffer.length = sizeof(printed_formatted);
     formatted_buffer.length = sizeof(printed_formatted);
     formatted_buffer.offset = 0;
     formatted_buffer.offset = 0;
     formatted_buffer.noalloc = true;
     formatted_buffer.noalloc = true;
-    formatted_buffer.hooks = global_hooks;
+    formatted_buffer.configuration = global_configuration;
 
 
     /* buffer for unformatted printing */
     /* buffer for unformatted printing */
     unformatted_buffer.buffer = printed_unformatted;
     unformatted_buffer.buffer = printed_unformatted;
     unformatted_buffer.length = sizeof(printed_unformatted);
     unformatted_buffer.length = sizeof(printed_unformatted);
     unformatted_buffer.offset = 0;
     unformatted_buffer.offset = 0;
     unformatted_buffer.noalloc = true;
     unformatted_buffer.noalloc = true;
-    unformatted_buffer.hooks = global_hooks;
+    unformatted_buffer.configuration = global_configuration;
 
 
     memset(item, 0, sizeof(item));
     memset(item, 0, sizeof(item));
     TEST_ASSERT_TRUE_MESSAGE(parse_object(item, &parsebuffer), "Failed to parse object.");
     TEST_ASSERT_TRUE_MESSAGE(parse_object(item, &parsebuffer), "Failed to parse object.");

+ 1 - 1
tests/print_string.c

@@ -32,7 +32,7 @@ static void assert_print_string(const char *expected, const char *input)
     buffer.length = sizeof(printed);
     buffer.length = sizeof(printed);
     buffer.offset = 0;
     buffer.offset = 0;
     buffer.noalloc = true;
     buffer.noalloc = true;
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     TEST_ASSERT_TRUE_MESSAGE(print_string_ptr((const unsigned char*)input, &buffer), "Failed to print string.");
     TEST_ASSERT_TRUE_MESSAGE(print_string_ptr((const unsigned char*)input, &buffer), "Failed to print string.");
     TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, printed, "The printed string isn't as expected.");
     TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, printed, "The printed string isn't as expected.");

+ 2 - 2
tests/print_value.c

@@ -38,11 +38,11 @@ static void assert_print_value(const char *input)
     buffer.length = sizeof(printed);
     buffer.length = sizeof(printed);
     buffer.offset = 0;
     buffer.offset = 0;
     buffer.noalloc = true;
     buffer.noalloc = true;
-    buffer.hooks = global_hooks;
+    buffer.configuration = global_configuration;
 
 
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.content = (const unsigned char*)input;
     parsebuffer.length = strlen(input) + sizeof("");
     parsebuffer.length = strlen(input) + sizeof("");
-    parsebuffer.hooks = global_hooks;
+    parsebuffer.configuration = global_configuration;
 
 
     memset(item, 0, sizeof(item));
     memset(item, 0, sizeof(item));