From 751999a82b8854ef5231e0ded5fe022b1ea5d8ff Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 4 Jul 2026 18:44:17 +0900 Subject: Harden backup import and restore coverage --- src/mcp/tools/common/memory_index.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/mcp/tools/common/memory_index.c') 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) { -- cgit v1.2.3