| 1163 | } |
| 1164 | |
| 1165 | CJSON_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 | |
| 1195 | CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) |
| 1196 | { |
nothing calls this directly
no test coverage detected