Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve const correctness #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions json-builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions json-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down