diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-09-21 12:24:23 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-09-22 11:43:16 +0200 |
commit | 0c8bd55b08a47493f6cde8a5ad9ca291fc262e6c (patch) | |
tree | 918d0d7f2d41a1eee08aeb49a3cb8b56750729c9 /lib | |
parent | 94a2b2b28738fc9e036fdc5ff177258f38e8ab6c (diff) | |
download | barebox-0c8bd55b08a47493f6cde8a5ad9ca291fc262e6c.tar.gz barebox-0c8bd55b08a47493f6cde8a5ad9ca291fc262e6c.tar.xz |
lib: jsmn: add and use new jsmn_token_size helper
To make code a bit more terse, add a simple helper to get a token's size
and start using it in some of the existing jsmn helpers.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230921102426.1109289-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/jsmn.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/jsmn.c b/lib/jsmn.c index 7bdcc90f2f..9eeed790d9 100644 --- a/lib/jsmn.c +++ b/lib/jsmn.c @@ -372,7 +372,7 @@ JSMN_API void jsmn_init(jsmn_parser *parser) { JSMN_API bool jsmn_eq(const char *val, const char *json, const jsmntok_t *token) { - size_t token_size = token->end - token->start; + size_t token_size = jsmn_token_size(token); return strlen(val) == token_size && strncmp(json + token->start, val, token_size) == 0; } @@ -446,7 +446,7 @@ JSMN_API char *jsmn_strcpy(const char *path[], const char *json, if (!node || node->type != JSMN_STRING) return NULL; - value_size = node->end - node->start; + value_size = jsmn_token_size(node); value = malloc(value_size + 1); if (value) { strncpy(value, json + node->start, value_size); |