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

Function cr_alloc

internal/cbm/result_compact.c:100–116  ·  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

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