A raw allocation of `bytes` in the new arena: MEASURE books it, COPY makes * it. Zero bytes is no allocation (the arena returns NULL for it too). */
| 98 | /* A raw allocation of `bytes` in the new arena: MEASURE books it, COPY makes |
| 99 | * it. Zero bytes is no allocation (the arena returns NULL for it too). */ |
| 100 | static void *cr_alloc(cr_ctx_t *c, size_t bytes) { |
| 101 | if (bytes == 0) { |
| 102 | return NULL; |
| 103 | } |
| 104 | if (c->phase == CR_MEASURE) { |
| 105 | c->bytes += cr_aligned(bytes); |
| 106 | return NULL; |
| 107 | } |
| 108 | if (c->phase == CR_COPY) { |
| 109 | void *p = cbm_arena_alloc(c->dst, bytes); |
| 110 | if (!p) { |
| 111 | c->failed = true; |
| 112 | } |
| 113 | return p; |
| 114 | } |
| 115 | return NULL; |
| 116 | } |
| 117 | |
| 118 | /* A string field: interned by content. COPY rewrites the field. */ |
| 119 | static void cr_str(cr_ctx_t *c, const char **field) { |
no test coverage detected