summaryrefslogtreecommitdiff
path: root/src/mcp/tools/common/memory_index.c
diff options
context:
space:
mode:
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)
{