| 237 | } |
| 238 | |
| 239 | bool tir_render(tir_context *c, tir_json *node, char **bytes, size_t *length, bool output) { |
| 240 | uint64_t bound = UINT64_MAX / 8; |
| 241 | size_t limit = bound < SIZE_MAX - 1 ? (size_t)bound : SIZE_MAX - 1; |
| 242 | if (output && c->limits->max_output_bytes < limit) |
| 243 | limit = c->limits->max_output_bytes; |
| 244 | tir_writer measure = {c, NULL, 0, limit}; |
| 245 | if (!tir_write_node(&measure, node)) |
| 246 | return false; |
| 247 | char *data = tir_alloc(c, measure.used + 1, 1); |
| 248 | if (!data) |
| 249 | return false; |
| 250 | tir_writer writer = {c, data, 0, measure.used}; |
| 251 | if (!tir_write_node(&writer, node)) |
| 252 | return false; |
| 253 | *bytes = data; |
| 254 | *length = writer.used; |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | static bool tir_hash_part(tir_context *c, cbm_sha256_ctx *hash, tir_bytes bytes) { |
| 259 | size_t length = bytes.length; |
no test coverage detected