diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-01-06 19:17:48 +0100 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-01-06 19:17:48 +0100 |
commit | 8a284c41724cadb53dded8929816789f0d682d6d (patch) | |
tree | 606949c8d1cb177daeacbbd4cda315a4bbbaee01 /src/print.c | |
parent | e079370a92766181ff5281c5d6cea03a1fce5b93 (diff) |
replace ssize_t and cast with int64_t
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/print.c b/src/print.c index 4b5c72c..dde40dd 100644 --- a/src/print.c +++ b/src/print.c @@ -2,9 +2,9 @@ #include <stdio.h> #include <json.h> -static bool append_printf(char **dest, size_t *size, size_t *index, const char *fmt, ...) { +static bool append_printf(char **dest, int64_t *size, int64_t *index, const char *fmt, ...) { va_list ap; - int len; + int64_t len; va_start(ap, fmt); len = vsnprintf(*dest + *index, *size - *index, fmt, ap); @@ -20,7 +20,7 @@ static bool append_printf(char **dest, size_t *size, size_t *index, const char * } // TODO: Fix this ugly cast - if (len < 0 || len >= (ssize_t)*size) { + if (len < 0 || len >= *size) { free(*dest); *dest = ""; return false; @@ -31,7 +31,7 @@ static bool append_printf(char **dest, size_t *size, size_t *index, const char * return true; } -void print_item(struct json *json, char **str, size_t *size, size_t *index) { +void print_item(struct json *json, char **str, int64_t *size, int64_t *index) { switch (json->type) { case JSON_OBJECT: append_printf(str, size, index, "{"); @@ -103,8 +103,8 @@ void print_item(struct json *json, char **str, size_t *size, size_t *index) { } char *json_print(struct json *json) { - size_t size = 1024; - size_t index = 0; + int64_t size = 1024; + int64_t index = 0; char *str = calloc(size, sizeof(char)); print_item(json, &str, &size, &index); return str; |