Skip to content

Commit 6c04e5a

Browse files
Improve const correctness
1 parent 9ba372c commit 6c04e5a

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
@@ -523,7 +523,7 @@ static size_t serialize_string (json_char * buf,
523523
return buf - orig_buf;
524524
}
525525

526-
size_t json_measure (json_value * value)
526+
size_t json_measure (const json_value * value)
527527
{
528528
return json_measure_ex (value, default_opts);
529529
}
@@ -533,7 +533,7 @@ size_t json_measure (json_value * value)
533533
indents += depth; \
534534
} while(0); \
535535

536-
size_t json_measure_ex (json_value * value, json_serialize_opts opts)
536+
size_t json_measure_ex (const json_value * value, json_serialize_opts opts)
537537
{
538538
size_t total = 1; /* null terminator */
539539
size_t newlines = 0;
@@ -701,7 +701,7 @@ size_t json_measure_ex (json_value * value, json_serialize_opts opts)
701701
return total;
702702
}
703703

704-
void json_serialize (json_char * buf, json_value * value)
704+
void json_serialize (json_char * buf, const json_value * value)
705705
{
706706
json_serialize_ex (buf, value, default_opts);
707707
}
@@ -728,7 +728,7 @@ void json_serialize (json_char * buf, json_value * value)
728728
*buf ++ = (c); \
729729
} while(0); \
730730

731-
void json_serialize_ex (json_char * buf, json_value * value, json_serialize_opts opts)
731+
void json_serialize_ex (json_char * buf, const json_value * value, json_serialize_opts opts)
732732
{
733733
json_int_t integer, orig_integer;
734734
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)