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

Function ej_push

src/pipeline/pass_envjoin.c:247–262  ·  view source on GitHub ↗

Appends `item` to the array table[key] (its count in counts[key]). */

Source from the content-addressed store, hash-verified

245
246/* Appends `item` to the array table[key] (its count in counts[key]). */
247static void ej_push(CBMArena *a, CBMHashTable *table, CBMHashTable *counts, const char *key,
248 const void *item, size_t size) {
249 intptr_t n = (intptr_t)cbm_ht_get(counts, key);
250 const char *old = cbm_ht_get(table, key);
251 char *v = cbm_arena_alloc(a, (size_t)(n + SKIP_ONE) * size);
252 const char *k = cbm_arena_strdup(a, key);
253 if (!v || !k) {
254 return;
255 }
256 if (n) {
257 memcpy(v, old, (size_t)n * size);
258 }
259 memcpy(v + (size_t)n * size, item, size);
260 cbm_ht_set(table, k, v);
261 cbm_ht_set(counts, k, (void *)(n + SKIP_ONE));
262}
263
264static const char *ej_id(ej_t *j, int64_t id) {
265 return cbm_arena_sprintf(&j->a, "%lld", (long long)id);

Callers 2

ej_add_imgFunction · 0.85
ej_add_readerFunction · 0.85

Calls 4

cbm_ht_getFunction · 0.85
cbm_ht_setFunction · 0.85
cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected