X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fdump.c;h=9c013665c61c2aeaf4e19ecf05ba1d111e97c428;hb=cf9b384bcbd2fab0bfb44e0165368d3abc965f32;hp=3f34919634e186d56d378c94d63a1806b0f41c56;hpb=68f2861e92e08eb5e2af51c026981bc1e990e1eb;p=jansson.git diff --git a/src/dump.c b/src/dump.c index 3f34919..9c01366 100644 --- a/src/dump.c +++ b/src/dump.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Petri Lehtinen + * Copyright (c) 2009-2011 Petri Lehtinen * * Jansson is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. @@ -41,8 +41,8 @@ static int dump_to_file(const char *buffer, int size, void *data) return 0; } -/* 256 spaces (the maximum indentation size) */ -static char whitespace[] = " "; +/* 32 spaces (the maximum indentation size) */ +static char whitespace[] = " "; static int dump_indent(size_t flags, int depth, int space, dump_func dump, void *data) { @@ -185,7 +185,9 @@ static int do_dump(const json_t *json, size_t flags, int depth, char buffer[MAX_INTEGER_STR_LENGTH]; int size; - size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, "%d", json_integer_value(json)); + size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, + "%" JSON_INTEGER_FORMAT, + json_integer_value(json)); if(size >= MAX_INTEGER_STR_LENGTH) return -1; @@ -311,7 +313,7 @@ static int do_dump(const json_t *json, size_t flags, int depth, int (*cmp_func)(const void *, const void *); size = json_object_size(json); - keys = malloc(size * sizeof(object_key_t *)); + keys = jsonp_malloc(size * sizeof(object_key_t *)); if(!keys) goto object_error; @@ -344,7 +346,7 @@ static int do_dump(const json_t *json, size_t flags, int depth, if(dump(separator, separator_length, data) || do_dump(value, flags, depth + 1, dump, data)) { - free(keys); + jsonp_free(keys); goto object_error; } @@ -353,7 +355,7 @@ static int do_dump(const json_t *json, size_t flags, int depth, if(dump(",", 1, data) || dump_indent(flags, depth + 1, 1, dump, data)) { - free(keys); + jsonp_free(keys); goto object_error; } } @@ -361,13 +363,13 @@ static int do_dump(const json_t *json, size_t flags, int depth, { if(dump_indent(flags, depth, 0, dump, data)) { - free(keys); + jsonp_free(keys); goto object_error; } } } - free(keys); + jsonp_free(keys); } else { @@ -430,7 +432,7 @@ char *json_dumps(const json_t *json, size_t flags) return NULL; } - result = strdup(strbuffer_value(&strbuff)); + result = jsonp_strdup(strbuffer_value(&strbuff)); strbuffer_close(&strbuff); return result;