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