MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / cJSON_PrintBuffered

Function cJSON_PrintBuffered

TheForceEngine/TFE_System/cJSON.c:1267–1295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1265}
1266
1267CJSON_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
1297CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
1298{

Callers

nothing calls this directly

Calls 2

print_valueFunction · 0.85
allocateMethod · 0.45

Tested by

no test coverage detected