A string field: interned by content. COPY rewrites the field. */
| 117 | |
| 118 | /* A string field: interned by content. COPY rewrites the field. */ |
| 119 | static void cr_str(cr_ctx_t *c, const char **field) { |
| 120 | const char *s = *field; |
| 121 | if (!s) { |
| 122 | return; |
| 123 | } |
| 124 | if (c->phase == CR_RELOCATE) { |
| 125 | if (cr_in_old_block(c, s)) { |
| 126 | *field = s + c->delta; |
| 127 | } |
| 128 | return; |
| 129 | } |
| 130 | if (c->phase == CR_COUNT) { |
| 131 | c->refs++; |
| 132 | return; |
| 133 | } |
| 134 | cr_slot_t *slot = cr_slot(c, s); |
| 135 | if (c->phase == CR_MEASURE) { |
| 136 | if (!slot->dst) { |
| 137 | slot->dst = (char *)s; /* mark as booked; reset before COPY */ |
| 138 | c->bytes += cr_aligned(slot->len + SKIP_ONE); |
| 139 | } |
| 140 | return; |
| 141 | } |
| 142 | if (!slot->dst) { |
| 143 | char *copy = (char *)cr_alloc(c, slot->len + SKIP_ONE); |
| 144 | if (!copy) { |
| 145 | return; |
| 146 | } |
| 147 | memcpy(copy, slot->src, slot->len + SKIP_ONE); |
| 148 | slot->dst = copy; |
| 149 | } |
| 150 | *field = slot->dst; |
| 151 | } |
| 152 | |
| 153 | /* A blob (fingerprint, retained source): copied verbatim. */ |
| 154 | static void cr_blob(cr_ctx_t *c, const void **field, size_t bytes) { |
no test coverage detected