MCPcopy Index your code
hub / github.com/antirez/botlib / cJSON_PrintBuffered

Function cJSON_PrintBuffered

cJSON.c:1258–1286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256}
1257
1258CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
1259{
1260 printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
1261
1262 if (prebuffer < 0)
1263 {
1264 return NULL;
1265 }
1266
1267 p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
1268 if (!p.buffer)
1269 {
1270 return NULL;
1271 }
1272
1273 p.length = (size_t)prebuffer;
1274 p.offset = 0;
1275 p.noalloc = false;
1276 p.format = fmt;
1277 p.hooks = global_hooks;
1278
1279 if (!print_value(item, &p))
1280 {
1281 global_hooks.deallocate(p.buffer);
1282 return NULL;
1283 }
1284
1285 return (char*)p.buffer;
1286}
1287
1288CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)
1289{

Callers

nothing calls this directly

Calls 1

print_valueFunction · 0.85

Tested by

no test coverage detected