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

Function cJSON_PrintBuffered

contrib/cJSON/cJSON.cpp:1178–1206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1176}
1177
1178CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
1179{
1180 printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
1181
1182 if (prebuffer < 0)
1183 {
1184 return NULL;
1185 }
1186
1187 p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
1188 if (!p.buffer)
1189 {
1190 return NULL;
1191 }
1192
1193 p.length = (size_t)prebuffer;
1194 p.offset = 0;
1195 p.noalloc = false;
1196 p.format = fmt;
1197 p.hooks = global_hooks;
1198
1199 if (!print_value(item, &p))
1200 {
1201 global_hooks.deallocate(p.buffer);
1202 return NULL;
1203 }
1204
1205 return (char*)p.buffer;
1206}
1207
1208CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt)
1209{

Callers

nothing calls this directly

Calls 3

print_valueFunction · 0.85
allocateMethod · 0.45
deallocateMethod · 0.45

Tested by

no test coverage detected