| 1176 | } |
| 1177 | |
| 1178 | CJSON_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 | |
| 1208 | CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) |
| 1209 | { |
nothing calls this directly
no test coverage detected