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

Function cr_alloc

internal/cbm/result_compact.c:109–125  ·  view source on GitHub ↗

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). */

Source from the content-addressed store, hash-verified

107/* A raw allocation of `bytes` in the new arena: MEASURE books it, COPY makes
108 * it. Zero bytes is no allocation (the arena returns NULL for it too). */
109static void *cr_alloc(cr_ctx_t *c, size_t bytes) {
110 if (bytes == 0) {
111 return NULL;
112 }
113 if (c->phase == CR_MEASURE) {
114 c->bytes += cr_aligned(bytes);
115 return NULL;
116 }
117 if (c->phase == CR_COPY) {
118 void *p = cbm_arena_alloc(c->dst, bytes);
119 if (!p) {
120 c->failed = true;
121 }
122 return p;
123 }
124 return NULL;
125}
126
127/* A string field: interned by content. COPY rewrites the field. */
128static void cr_str(cr_ctx_t *c, const char **field) {

Callers 2

cr_strFunction · 0.85
cr_blobFunction · 0.85

Calls 2

cr_alignedFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected