MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / cJSON_PrintBuffered

Function cJSON_PrintBuffered

external/cJSON/cJSON.c:1317–1346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1315}
1316
1317CJSON_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
1348CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
1349{

Callers

nothing calls this directly

Calls 3

print_valueFunction · 0.85
allocateMethod · 0.45
deallocateMethod · 0.45

Tested by

no test coverage detected