MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cr_str

Function cr_str

internal/cbm/result_compact.c:119–151  ·  view source on GitHub ↗

A string field: interned by content. COPY rewrites the field. */

Source from the content-addressed store, hash-verified

117
118/* A string field: interned by content. COPY rewrites the field. */
119static 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. */
154static void cr_blob(cr_ctx_t *c, const void **field, size_t bytes) {

Callers 5

cr_listFunction · 0.85
cr_counted_listFunction · 0.85
cr_walk_defFunction · 0.85
cr_walk_callFunction · 0.85
cr_walkFunction · 0.85

Calls 4

cr_in_old_blockFunction · 0.85
cr_slotFunction · 0.85
cr_alignedFunction · 0.85
cr_allocFunction · 0.85

Tested by

no test coverage detected