diff options
author | Petri Lehtinen <petri@digip.org> | 2017-08-19 21:10:11 +0300 |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2017-08-19 21:10:17 +0300 |
commit | 271ffda903d2b64e3971f41a3e03af1ad0ddc217 (patch) | |
tree | d6a914d3a9aa3d0e144102b4b2960c2c88640ff4 | |
parent | 3e5405c39e63c33b5ca07c6b4f7bdd53e7846b4c (diff) | |
download | jansson-271ffda903d2b64e3971f41a3e03af1ad0ddc217.zip jansson-271ffda903d2b64e3971f41a3e03af1ad0ddc217.tar.gz jansson-271ffda903d2b64e3971f41a3e03af1ad0ddc217.tar.bz2 |
Make json_equal() const-correct
Fixes #344
-rw-r--r-- | src/jansson.h | 2 | ||||
-rw-r--r-- | src/value.c | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/jansson.h b/src/jansson.h index f55a387..a92a9ac 100644 --- a/src/jansson.h +++ b/src/jansson.h @@ -251,7 +251,7 @@ int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char /* equality */ -int json_equal(json_t *value1, json_t *value2); +int json_equal(const json_t *value1, const json_t *value2); /* copying */ diff --git a/src/value.c b/src/value.c index 82e60a5..86fda0a 100644 --- a/src/value.c +++ b/src/value.c @@ -272,15 +272,15 @@ void *json_object_key_to_iter(const char *key) return hashtable_key_to_iter(key); } -static int json_object_equal(json_t *object1, json_t *object2) +static int json_object_equal(const json_t *object1, const json_t *object2) { const char *key; - json_t *value1, *value2; + const json_t *value1, *value2; if(json_object_size(object1) != json_object_size(object2)) return 0; - json_object_foreach(object1, key, value1) { + json_object_foreach((json_t *)object1, key, value1) { value2 = json_object_get(object2, key); if(!json_equal(value1, value2)) @@ -581,7 +581,7 @@ int json_array_extend(json_t *json, json_t *other_json) return 0; } -static int json_array_equal(json_t *array1, json_t *array2) +static int json_array_equal(const json_t *array1, const json_t *array2) { size_t i, size; @@ -765,7 +765,7 @@ static void json_delete_string(json_string_t *string) jsonp_free(string); } -static int json_string_equal(json_t *string1, json_t *string2) +static int json_string_equal(const json_t *string1, const json_t *string2) { json_string_t *s1, *s2; @@ -825,7 +825,7 @@ static void json_delete_integer(json_integer_t *integer) jsonp_free(integer); } -static int json_integer_equal(json_t *integer1, json_t *integer2) +static int json_integer_equal(const json_t *integer1, const json_t *integer2) { return json_integer_value(integer1) == json_integer_value(integer2); } @@ -877,7 +877,7 @@ static void json_delete_real(json_real_t *real) jsonp_free(real); } -static int json_real_equal(json_t *real1, json_t *real2) +static int json_real_equal(const json_t *real1, const json_t *real2) { return json_real_value(real1) == json_real_value(real2); } @@ -957,7 +957,7 @@ void json_delete(json_t *json) /*** equality ***/ -int json_equal(json_t *json1, json_t *json2) +int json_equal(const json_t *json1, const json_t *json2) { if(!json1 || !json2) return 0; |