MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_PrintBuffered

Function cJSON_PrintBuffered

libapp2sys/src/main/cpp/cjson/cJSON.c:1165–1193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1163}
1164
1165CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)
1166{
1167 printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
1168
1169 if (prebuffer < 0)
1170 {
1171 return NULL;
1172 }
1173
1174 p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer);
1175 if (!p.buffer)
1176 {
1177 return NULL;
1178 }
1179
1180 p.length = (size_t)prebuffer;
1181 p.offset = 0;
1182 p.noalloc = false;
1183 p.format = fmt;
1184 p.hooks = global_hooks;
1185
1186 if (!print_value(item, &p))
1187 {
1188 global_hooks.deallocate(p.buffer);
1189 return NULL;
1190 }
1191
1192 return (char*)p.buffer;
1193}
1194
1195CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt)
1196{

Callers

nothing calls this directly

Calls 3

print_valueFunction · 0.85
allocateMethod · 0.80
deallocateMethod · 0.80

Tested by

no test coverage detected