MCPcopy Create free account
hub / github.com/antirez/ds4 / kv_cache_restore_tool_memory_for_messages

Function kv_cache_restore_tool_memory_for_messages

ds4_server.c:8542–8581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8540 return m && m->max_entries > 0 ? m->max_entries : DS4_TOOL_MEMORY_DEFAULT_MAX_IDS;
8541}
8542
8543static size_t tool_memory_max_bytes(const tool_memory *m) {
8544 return m && m->max_bytes > 0 ? m->max_bytes : DS4_TOOL_MEMORY_MAX_BYTES;
8545}
8546
8547static void tool_memory_init_locked(tool_memory *m) {
8548 if (m->by_id && m->by_block) return;
8549 m->by_id = raxNew();
8550 m->by_block = raxNew();
8551 if (!m->by_id || !m->by_block) die("out of memory");
8552}
8553
8554static void tool_memory_link_head(tool_memory *m, tool_memory_entry *e) {
8555 e->prev = NULL;
8556 e->next = m->head;
8557 if (m->head) m->head->prev = e;
8558 else m->tail = e;
8559 m->head = e;
8560}
8561
8562static void tool_memory_unlink(tool_memory *m, tool_memory_entry *e) {
8563 if (e->prev) e->prev->next = e->next;
8564 else m->head = e->next;
8565 if (e->next) e->next->prev = e->prev;
8566 else m->tail = e->prev;
8567 e->prev = e->next = NULL;
8568}
8569
8570static void tool_memory_touch(tool_memory *m, tool_memory_entry *e) {
8571 e->stamp = ++m->clock;
8572 if (m->head == e) return;
8573 tool_memory_unlink(m, e);
8574 tool_memory_link_head(m, e);
8575}
8576
8577static void tool_block_unlink_entry(tool_memory_block *b, tool_memory_entry *e) {
8578 tool_memory_entry **p = &b->entries;
8579 while (*p) {
8580 if (*p == e) {
8581 *p = e->block_next;
8582 e->block_next = NULL;
8583 return;
8584 }

Calls 7

collect_tool_call_idsFunction · 0.85
ds4_engine_model_idFunction · 0.85
id_list_freeFunction · 0.85
sha_hex_nameFunction · 0.85
kv_read_headerFunction · 0.85
path_joinFunction · 0.70