MCPcopy Create free account
hub / github.com/Netis/cloud-probe / compare_strings

Function compare_strings

cpworker/src/cJSON/cJSON_Utils.c:82–108  ·  view source on GitHub ↗

string comparison which doesn't consider NULL pointers equal */

Source from the content-addressed store, hash-verified

80
81/* string comparison which doesn't consider NULL pointers equal */
82static int compare_strings(const unsigned char *string1, const unsigned char *string2, const cJSON_bool case_sensitive)
83{
84 if ((string1 == NULL) || (string2 == NULL))
85 {
86 return 1;
87 }
88
89 if (string1 == string2)
90 {
91 return 0;
92 }
93
94 if (case_sensitive)
95 {
96 return strcmp((const char *)string1, (const char *)string2);
97 }
98
99 for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
100 {
101 if (*string1 == '\0')
102 {
103 return 0;
104 }
105 }
106
107 return tolower(*string1) - tolower(*string2);
108}
109
110/* securely comparison of floating-point variables */
111static cJSON_bool compare_double(double a, double b)

Callers 3

sort_listFunction · 0.85
compare_jsonFunction · 0.85
create_patchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected