Skip to content

Commit

Permalink
Use sizeof(seq) instead of magic number 13
Browse files Browse the repository at this point in the history
Be more future proof by keeping the number of magic constants low.
  • Loading branch information
gonzzor committed Oct 5, 2015
1 parent 0246486 commit f7331c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
/* codepoint is in BMP */
if(codepoint < 0x10000)
{
snprintf(seq, 13, "\\u%04X", codepoint);
snprintf(seq, sizeof(seq), "\\u%04X", codepoint);
length = 6;
}

Expand All @@ -147,7 +147,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
last = 0xDC00 | (codepoint & 0x003ff);

snprintf(seq, 13, "\\u%04X\\u%04X", first, last);
snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", first, last);
length = 12;
}

Expand Down

0 comments on commit f7331c7

Please sign in to comment.