Skip to content

Commit 84eb75a

Browse files
Improve const correctness
1 parent fffd849 commit 84eb75a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

json-builder.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static size_t serialize_string (json_char * buf,
524524
return buf - orig_buf;
525525
}
526526

527-
size_t json_measure (json_value * value)
527+
size_t json_measure (const json_value * value)
528528
{
529529
return json_measure_ex (value, default_opts);
530530
}
@@ -534,7 +534,7 @@ size_t json_measure (json_value * value)
534534
indents += depth; \
535535
} while(0); \
536536

537-
size_t json_measure_ex (json_value * value, json_serialize_opts opts)
537+
size_t json_measure_ex (const json_value * value, json_serialize_opts opts)
538538
{
539539
size_t total = 1; /* null terminator */
540540
size_t newlines = 0;
@@ -702,7 +702,7 @@ size_t json_measure_ex (json_value * value, json_serialize_opts opts)
702702
return total;
703703
}
704704

705-
void json_serialize (json_char * buf, json_value * value)
705+
void json_serialize (json_char * buf, const json_value * value)
706706
{
707707
json_serialize_ex (buf, value, default_opts);
708708
}
@@ -729,7 +729,7 @@ void json_serialize (json_char * buf, json_value * value)
729729
*buf ++ = (c); \
730730
} while(0); \
731731

732-
void json_serialize_ex (json_char * buf, json_value * value, json_serialize_opts opts)
732+
void json_serialize_ex (json_char * buf, const json_value * value, json_serialize_opts opts)
733733
{
734734
json_int_t integer, orig_integer;
735735
json_object_entry * entry;

json-builder.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ typedef struct json_serialize_opts
134134
/* Returns a length in characters that is at least large enough to hold the
135135
* value in its serialized form, including a null terminator.
136136
*/
137-
size_t json_measure (json_value *);
138-
size_t json_measure_ex (json_value *, json_serialize_opts);
137+
size_t json_measure (const json_value *);
138+
size_t json_measure_ex (const json_value *, json_serialize_opts);
139139

140140

141141
/* Serializes a JSON value into the buffer given (which must already be
142142
* allocated with a length of at least json_measure(value, opts))
143143
*/
144-
void json_serialize (json_char * buf, json_value *);
145-
void json_serialize_ex (json_char * buf, json_value *, json_serialize_opts);
144+
void json_serialize (json_char * buf, const json_value *);
145+
void json_serialize_ex (json_char * buf, const json_value *, json_serialize_opts);
146146

147147

148148
/*** Cleaning up

0 commit comments

Comments
 (0)