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

Function gm_set_add

src/store/graph_mem.c:641–656  ·  view source on GitHub ↗

1 = added, 0 = already present, -1 = out of memory. */

Source from the content-addressed store, hash-verified

639
640/* 1 = added, 0 = already present, -1 = out of memory. */
641static int gm_set_add(gm_set_t *s, uint32_t id) {
642 if ((s->count + 1) * GM_SET_LOAD_DEN > s->cap * GM_SET_LOAD_NUM && !gm_set_grow(s)) {
643 return -1;
644 }
645 size_t mask = s->cap - 1;
646 for (size_t i = gm_set_home(id, mask);; i = (i + 1) & mask) {
647 if (s->slots[i] == 0) {
648 s->slots[i] = id + 1;
649 s->count++;
650 return 1;
651 }
652 if (s->slots[i] == id + 1) {
653 return 0;
654 }
655 }
656}
657
658typedef struct {
659 uint32_t *ids;

Callers 1

gm_expand_levelFunction · 0.85

Calls 2

gm_set_growFunction · 0.85
gm_set_homeFunction · 0.85

Tested by

no test coverage detected