summaryrefslogtreecommitdiff
path: root/src/mcp/tools/common/history.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/history.c
parent21dda921887da2515d1eba0d3d26e2036bf9f7f7 (diff)
Harden backup import and restore coverage
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)
{