summaryrefslogtreecommitdiff
path: root/src/domain/search.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/domain/search.c
parent21dda921887da2515d1eba0d3d26e2036bf9f7f7 (diff)
Harden backup import and restore coverage
Diffstat (limited to 'src/domain/search.c')
-rw-r--r--src/domain/search.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/domain/search.c b/src/domain/search.c
index faf16ff..e34cc72 100644
--- a/src/domain/search.c
+++ b/src/domain/search.c
@@ -356,6 +356,24 @@ tiny_search_index_create(void)
return calloc(1, sizeof(tiny_search_index_t));
}
+uint64_t
+tiny_search_index_memory_estimate(const tiny_search_index_t *index)
+{
+ uint64_t total;
+ size_t position;
+ if (!index)
+ {
+ return 0;
+ }
+ total = sizeof(*index) + index->bucket_capacity * sizeof(*index->buckets)
+ + index->slot_capacity * sizeof(*index->slots);
+ for (position = 0; position < index->bucket_count; ++position)
+ {
+ total += index->buckets[position].capacity * sizeof(*index->buckets[position].messages);
+ }
+ return total;
+}
+
void
tiny_search_index_free(tiny_search_index_t *index)
{
@@ -710,4 +728,4 @@ tiny_search_score(const char *query, const tiny_message_t *message)
return 0.0;
}
return breakdown.total;
-} \ No newline at end of file
+}