static int dump_to_fd(const char *buffer, size_t size, void *data)
{
- int *dest = (int *)data;
#ifdef HAVE_UNISTD_H
+ int *dest = (int *)data;
if(write(*dest, buffer, size) == (ssize_t)size)
return 0;
#endif
static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data, size_t flags)
{
const char *pos, *end, *lim;
- int32_t codepoint;
+ int32_t codepoint = 0;
if(dump("\"", 1, data))
return -1;
const char *separator;
int separator_length;
/* Space for "0x", double the sizeof a pointer for the hex and a terminator. */
- char key[2 + (sizeof(json) * 2) + 1];
+ char loop_key[2 + (sizeof(json) * 2) + 1];
if(flags & JSON_COMPACT) {
separator = ":";
}
/* detect circular references */
- if (loop_check(parents, json, key, sizeof(key)))
+ if (loop_check(parents, json, loop_key, sizeof(loop_key)))
return -1;
iter = json_object_iter((json_t *)json);
if(!embed && dump("{", 1, data))
return -1;
if(!iter) {
- hashtable_del(parents, key);
+ hashtable_del(parents, loop_key);
return embed ? 0 : dump("}", 1, data);
}
if(dump_indent(flags, depth + 1, 0, dump, data))
}
}
- hashtable_del(parents, key);
+ hashtable_del(parents, loop_key);
return embed ? 0 : dump("}", 1, data);
}