Rename internal_hooks -> internal_configuration, cJSON_New_item -> create_item

This commit is contained in:
Max Bruckner
2018-01-31 22:22:53 +01:00
parent e82f32b359
commit b277cd6a24
12 changed files with 110 additions and 110 deletions

View File

@@ -33,11 +33,11 @@ void reset(cJSON *item) {
}
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))
{
global_hooks.deallocate(item->string);
global_configuration.deallocate(item->string);
}
memset(item, 0, sizeof(cJSON));

View File

@@ -432,7 +432,7 @@ static void skip_utf8_bom_should_skip_bom(void)
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
buffer.content = string;
buffer.length = sizeof(string);
buffer.hooks = global_hooks;
buffer.configuration = global_configuration;
TEST_ASSERT_TRUE(skip_utf8_bom(&buffer) == &buffer);
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 } };
buffer.content = string;
buffer.length = sizeof(string);
buffer.hooks = global_hooks;
buffer.configuration = global_configuration;
buffer.offset = 1;
TEST_ASSERT_NULL(skip_utf8_bom(&buffer));

View File

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

View File

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

View File

@@ -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 } };
buffer.content = (const unsigned char*)string;
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.");
assert_is_string(item);
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;
}
@@ -62,7 +62,7 @@ static void assert_not_parse_string(const char * const string)
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
buffer.content = (const unsigned char*)string;
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.");
assert_is_invalid(item);

View File

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

View File

@@ -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 } };
parsebuffer.content = (const unsigned char*)input;
parsebuffer.length = strlen(input) + sizeof("");
parsebuffer.hooks = global_hooks;
parsebuffer.configuration = global_configuration;
/* buffer for formatted printing */
formatted_buffer.buffer = printed_formatted;
formatted_buffer.length = sizeof(printed_formatted);
formatted_buffer.offset = 0;
formatted_buffer.noalloc = true;
formatted_buffer.hooks = global_hooks;
formatted_buffer.configuration = global_configuration;
/* buffer for unformatted printing */
unformatted_buffer.buffer = printed_unformatted;
unformatted_buffer.length = sizeof(printed_unformatted);
unformatted_buffer.offset = 0;
unformatted_buffer.noalloc = true;
unformatted_buffer.hooks = global_hooks;
unformatted_buffer.configuration = global_configuration;
memset(item, 0, sizeof(item));
TEST_ASSERT_TRUE_MESSAGE(parse_array(item, &parsebuffer), "Failed to parse array.");

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ static void assert_print_string(const char *expected, const char *input)
buffer.length = sizeof(printed);
buffer.offset = 0;
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_EQUAL_STRING_MESSAGE(expected, printed, "The printed string isn't as expected.");

View File

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