From c21efcbaee57e31461a445d0db94f9d0c2ac3f6f Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Fri, 19 Jan 2018 00:11:07 +0100 Subject: [PATCH] print: Comment about why the buffer is reallocated --- cJSON.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cJSON.c b/cJSON.c index cbdec41..3c93618 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1109,6 +1109,8 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i } update_offset(buffer); + /* Reallocate the buffer so that it only uses as much as it needs. + This can save up to 50% because ensure increases the buffer size by a factor of 2 */ /* check if reallocate is available */ if (hooks->reallocate != NULL) {