summaryrefslogtreecommitdiff
path: root/src/mcp/tools/common/history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mcp/tools/common/history.c')
-rw-r--r--src/mcp/tools/common/history.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mcp/tools/common/history.c b/src/mcp/tools/common/history.c
index 9f08e84..0e600d4 100644
--- a/src/mcp/tools/common/history.c
+++ b/src/mcp/tools/common/history.c
@@ -245,6 +245,25 @@ tiny_history_index_build(const tiny_store_t *store)
return index;
}
+uint64_t
+tiny_history_index_memory_estimate(const tiny_history_index_t *index)
+{
+ uint64_t total;
+ size_t position;
+ if (!index)
+ {
+ return 0;
+ }
+ total = sizeof(*index) + index->capacity * sizeof(*index->buckets)
+ + index->slot_capacity * sizeof(*index->slots);
+ for (position = 0; position < index->count; ++position)
+ {
+ total += strlen(index->buckets[position].session_id) + 1;
+ total += index->buckets[position].capacity * sizeof(*index->buckets[position].entries);
+ }
+ return total;
+}
+
void
tiny_history_index_free(tiny_history_index_t *index)
{