浏览代码

print: Comment about why the buffer is reallocated

Max Bruckner 7 年之前
父节点
当前提交
06f4152008
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      cJSON.c

+ 2 - 0
cJSON.c

@@ -1110,6 +1110,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)
     {