MCPcopy Create free account
hub / github.com/OpenIPC/firmware / cJSON_PrintBuffered

Function cJSON_PrintBuffered

general/package/xmdp/src/cjson/cJSON.c:1256–1284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

print_valueFunction · 0.85

Tested by

no test coverage detected