summaryrefslogtreecommitdiff
path: root/src/mcp/tools/common/memory_index.c
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-07-04 18:44:17 +0900
committertanaka takashi <isazaka@gmail.com>2026-07-04 18:44:17 +0900
commit751999a82b8854ef5231e0ded5fe022b1ea5d8ff (patch)
treed09653d2955f0f5354e9ef76f9bc550fb8f0732a /src/mcp/tools/common/memory_index.c
parent21dda921887da2515d1eba0d3d26e2036bf9f7f7 (diff)
Harden backup import and restore coverage
Diffstat (limited to 'src/mcp/tools/common/memory_index.c')
-rw-r--r--src/mcp/tools/common/memory_index.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mcp/tools/common/memory_index.c b/src/mcp/tools/common/memory_index.c
index e3841e2..32a97d1 100644
--- a/src/mcp/tools/common/memory_index.c
+++ b/src/mcp/tools/common/memory_index.c
@@ -165,6 +165,25 @@ tiny_memory_index_build(const tiny_store_t *store)
return index;
}
+uint64_t
+tiny_memory_index_memory_estimate(const tiny_memory_index_t *index)
+{
+ uint64_t total;
+ size_t position;
+ if (!index)
+ {
+ return 0;
+ }
+ total = sizeof(*index) + index->count * sizeof(*index->buckets)
+ + index->slot_capacity * sizeof(*index->slots);
+ for (position = 0; position < index->count; ++position)
+ {
+ total += index->buckets[position].incoming_capacity
+ * sizeof(*index->buckets[position].incoming);
+ }
+ return total;
+}
+
void
tiny_memory_index_free(tiny_memory_index_t *index)
{