summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/print.c12
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;