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

Function cbm_realloc

src/foundation/mem_core.c:283–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void *cbm_realloc(cbm_mem_class_t cls, void *block, size_t bytes) {
284 if (!block) {
285 return cbm_alloc(cls, bytes);
286 }
287 check_owned(block, "realloc");
288 /* Measure BEFORE: after realloc the old block is gone and its size is
289 * unknowable, so the decrement has to be computed first. */
290 size_t old = charge_size(block, 0);
291 MEMEV_HINT(cls);
292 CBM_MEMEV_BACKING(1);
293 void *next = CBM_BACKING_REALLOC(block, bytes ? bytes : CBM_ALLOC_ONE);
294 CBM_MEMEV_BACKING(-1);
295 MEMEV_REALLOCATED(block, next, bytes);
296 if (!next) {
297 return NULL; /* original intact and still charged - correct */
298 }
299 class_sub(cls, old, 0);
300 class_add(cls, charge_size(next, bytes), 0);
301 return next;
302}
303
304char *cbm_mem_strdup(cbm_mem_class_t cls, const char *s) {
305 if (!s) {

Callers 15

md_push_intFunction · 0.85
u32_pushFunction · 0.85
cand_pushFunction · 0.85
sb_putFunction · 0.85
scan_pageFunction · 0.85
wd_growFunction · 0.85
cbm_walk_stack_reserveFunction · 0.85
sqlv_pushFunction · 0.85
g2uFunction · 0.85
ivl_pushFunction · 0.85
el_pushFunction · 0.85
cm_flushFunction · 0.85

Calls 5

cbm_allocFunction · 0.85
check_ownedFunction · 0.85
charge_sizeFunction · 0.85
class_subFunction · 0.85
class_addFunction · 0.85

Tested by 5

te_read_fileFunction · 0.68
ti_growFunction · 0.68
ts_growFunction · 0.68
ta_yy_reallocFunction · 0.68
te_growFunction · 0.68