From 84eb75a53ef9b093cc8d501a7719a45409c56c6f Mon Sep 17 00:00:00 2001 From: Marco Tiraboschi Date: Mon, 10 Aug 2020 17:01:01 +0200 Subject: [PATCH] Improve const correctness --- json-builder.c | 8 ++++---- json-builder.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/json-builder.c b/json-builder.c index 2b96e6d..dc6d6fd 100644 --- a/json-builder.c +++ b/json-builder.c @@ -524,7 +524,7 @@ static size_t serialize_string (json_char * buf, return buf - orig_buf; } -size_t json_measure (json_value * value) +size_t json_measure (const json_value * value) { return json_measure_ex (value, default_opts); } @@ -534,7 +534,7 @@ size_t json_measure (json_value * value) indents += depth; \ } while(0); \ -size_t json_measure_ex (json_value * value, json_serialize_opts opts) +size_t json_measure_ex (const json_value * value, json_serialize_opts opts) { size_t total = 1; /* null terminator */ size_t newlines = 0; @@ -702,7 +702,7 @@ size_t json_measure_ex (json_value * value, json_serialize_opts opts) return total; } -void json_serialize (json_char * buf, json_value * value) +void json_serialize (json_char * buf, const json_value * value) { json_serialize_ex (buf, value, default_opts); } @@ -729,7 +729,7 @@ void json_serialize (json_char * buf, json_value * value) *buf ++ = (c); \ } while(0); \ -void json_serialize_ex (json_char * buf, json_value * value, json_serialize_opts opts) +void json_serialize_ex (json_char * buf, const json_value * value, json_serialize_opts opts) { json_int_t integer, orig_integer; json_object_entry * entry; diff --git a/json-builder.h b/json-builder.h index 29a36ff..735698b 100644 --- a/json-builder.h +++ b/json-builder.h @@ -134,15 +134,15 @@ typedef struct json_serialize_opts /* Returns a length in characters that is at least large enough to hold the * value in its serialized form, including a null terminator. */ -size_t json_measure (json_value *); -size_t json_measure_ex (json_value *, json_serialize_opts); +size_t json_measure (const json_value *); +size_t json_measure_ex (const json_value *, json_serialize_opts); /* Serializes a JSON value into the buffer given (which must already be * allocated with a length of at least json_measure(value, opts)) */ -void json_serialize (json_char * buf, json_value *); -void json_serialize_ex (json_char * buf, json_value *, json_serialize_opts); +void json_serialize (json_char * buf, const json_value *); +void json_serialize_ex (json_char * buf, const json_value *, json_serialize_opts); /*** Cleaning up