| 1265 | } |
| 1266 | |
| 1267 | CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) |
| 1268 | { |
| 1269 | printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; |
| 1270 | |
| 1271 | if (prebuffer < 0) |
| 1272 | { |
| 1273 | return NULL; |
| 1274 | } |
| 1275 | |
| 1276 | p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); |
| 1277 | if (!p.buffer) |
| 1278 | { |
| 1279 | return NULL; |
| 1280 | } |
| 1281 | |
| 1282 | p.length = (size_t)prebuffer; |
| 1283 | p.offset = 0; |
| 1284 | p.noalloc = false; |
| 1285 | p.format = fmt; |
| 1286 | p.hooks = global_hooks; |
| 1287 | |
| 1288 | if (!print_value(item, &p)) |
| 1289 | { |
| 1290 | global_hooks.deallocate(p.buffer); |
| 1291 | return NULL; |
| 1292 | } |
| 1293 | |
| 1294 | return (char*)p.buffer; |
| 1295 | } |
| 1296 | |
| 1297 | CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) |
| 1298 | { |
nothing calls this directly
no test coverage detected