| 1315 | } |
| 1316 | |
| 1317 | CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) |
| 1318 | { |
| 1319 | printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; |
| 1320 | |
| 1321 | if (prebuffer < 0) |
| 1322 | { |
| 1323 | return NULL; |
| 1324 | } |
| 1325 | |
| 1326 | p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); |
| 1327 | if (!p.buffer) |
| 1328 | { |
| 1329 | return NULL; |
| 1330 | } |
| 1331 | |
| 1332 | p.length = (size_t)prebuffer; |
| 1333 | p.offset = 0; |
| 1334 | p.noalloc = false; |
| 1335 | p.format = fmt; |
| 1336 | p.hooks = global_hooks; |
| 1337 | |
| 1338 | if (!print_value(item, &p)) |
| 1339 | { |
| 1340 | global_hooks.deallocate(p.buffer); |
| 1341 | p.buffer = NULL; |
| 1342 | return NULL; |
| 1343 | } |
| 1344 | |
| 1345 | return (char*)p.buffer; |
| 1346 | } |
| 1347 | |
| 1348 | CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) |
| 1349 | { |
nothing calls this directly
no test coverage detected