MCPcopy Create free account
hub / github.com/Netis/cloud-probe / cJSON_PrintBuffered

Function cJSON_PrintBuffered

cpworker/src/cJSON/cJSON.c:1274–1303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272}
1273
1274CJSON_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
1305CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
1306{

Callers

nothing calls this directly

Calls 1

print_valueFunction · 0.85

Tested by

no test coverage detected