mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
print: Fix default buffer size in printbuffer
Thanks @liuyunbin for reporting this in #230
This commit is contained in:
parent
984dc85a5f
commit
f33fa95f3d
4
cJSON.c
4
cJSON.c
@ -1087,13 +1087,15 @@ CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value)
|
|||||||
|
|
||||||
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
|
static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks)
|
||||||
{
|
{
|
||||||
|
static const size_t default_buffer_size = 256;
|
||||||
printbuffer buffer[1];
|
printbuffer buffer[1];
|
||||||
unsigned char *printed = NULL;
|
unsigned char *printed = NULL;
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
/* create buffer */
|
/* create buffer */
|
||||||
buffer->buffer = (unsigned char*) hooks->allocate(256);
|
buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
|
||||||
|
buffer->length = default_buffer_size;
|
||||||
buffer->format = format;
|
buffer->format = format;
|
||||||
buffer->hooks = *hooks;
|
buffer->hooks = *hooks;
|
||||||
if (buffer->buffer == NULL)
|
if (buffer->buffer == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user