Reorder the context fields

This commit is contained in:
Max Bruckner 2018-03-25 23:27:35 +02:00
parent 1b001ab047
commit 08738673be
2 changed files with 10 additions and 10 deletions

18
cJSON.c
View File

@ -119,13 +119,13 @@ static int case_insensitive_strcmp(const unsigned char *string1, const unsigned
typedef struct internal_context
{
size_t buffer_size;
size_t end_position;
void *userdata;
cJSON_Allocators allocators;
cJSON_bool format;
cJSON_bool allow_data_after_json;
cJSON_bool case_sensitive;
cJSON_bool duplicate_recursive;
cJSON_Allocators allocators;
void *userdata;
size_t end_position;
} internal_context;
#if defined(_MSC_VER)
@ -194,17 +194,17 @@ static void deallocate(const internal_context * const context, void *pointer)
#define default_context {\
256, /* default buffer size */\
true, /* enable formatting by default */\
true, /* allow data after the JSON by default */\
true, /* case sensitive by default */\
true, /* Do cJSON_Duplicate recursively by default */\
0, /* default end position */\
NULL, /* no userdata */\
{\
malloc_wrapper,\
free_wrapper,\
realloc_wrapper\
},\
NULL, /* no userdata */\
0 /* default end position */\
true, /* enable formatting by default */\
true, /* allow data after the JSON by default */\
true, /* case sensitive by default */\
true /* Do cJSON_Duplicate recursively by default */\
}
/* this is necessary to assign the default context after initialization */

View File

@ -419,7 +419,7 @@ static void *failing_realloc(void *pointer, size_t size, void *userdata)
static void ensure_should_fail_on_failed_realloc(void)
{
printbuffer buffer = {NULL, 10, 0, 0, false, {256, false, true, true, true, {malloc_wrapper, free_wrapper, failing_realloc}, NULL, 0 } };
printbuffer buffer = {NULL, 10, 0, 0, false, {256, 0, NULL, {malloc_wrapper, free_wrapper, failing_realloc}, false, true, true, true} };
buffer.context.userdata = &buffer;
buffer.buffer = (unsigned char*)malloc(100);
TEST_ASSERT_NOT_NULL(buffer.buffer);