From ade870f38ac59bcf72f687033702e89bb680ca3c Mon Sep 17 00:00:00 2001 From: ArFe Date: Thu, 14 Sep 2023 15:04:48 -0400 Subject: [PATCH 1/2] Fix code snippet for cJSON_Duplicate and cJSON_Compare --- cJSON.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cJSON.h b/cJSON.h index 2628d763..2faafd5e 100644 --- a/cJSON.h +++ b/cJSON.h @@ -245,11 +245,12 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); -/* Duplicate a cJSON item */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); -/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will +/* Duplicate a cJSON item + * Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will * need to be released. With recurse!=0, it will duplicate any children connected to the item. * The item->next and ->prev pointers are always zero on return from Duplicate. */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); + /* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); From f20d086ca97e9260553ccec708009da916e1e7df Mon Sep 17 00:00:00 2001 From: ArFe Date: Thu, 14 Sep 2023 15:22:20 -0400 Subject: [PATCH 2/2] Add expected results to cJSON_Compare (true if equal, false otherwise) --- cJSON.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cJSON.h b/cJSON.h index 2faafd5e..10494325 100644 --- a/cJSON.h +++ b/cJSON.h @@ -251,7 +251,8 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,co * The item->next and ->prev pointers are always zero on return from Duplicate. */ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); -/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. +/* Recursively compare two cJSON items for equality. Return true if equal, false otherwise. + * If either a or b is NULL or invalid, they will be considered unequal. * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);