summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/search.cpp10
-rw-r--r--src/search.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/search.cpp b/src/search.cpp
index fe039bd..3f1f496 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -353,6 +353,13 @@ finish_early:;
return 0;
}
+void ts_destroy_result(ts_search_result* result) {
+ ts_memory_bucket_destroy(&result->memory);
+ ts_array_destroy(&result->files);
+ ts_array_destroy(&result->matches);
+ free(result);
+}
+
static void *_ts_list_files_thread(void *args)
{
ts_search_result *info = (ts_search_result *)args;
@@ -364,8 +371,7 @@ static void *_ts_list_files_thread(void *args)
while (!info->prev_result->search_completed) {
ts_thread_sleep(10);
}
- ts_memory_bucket_destroy(&info->prev_result->memory);
- free(info->prev_result);
+ ts_destroy_result(info->prev_result);
info->prev_result = nullptr;
}
diff --git a/src/search.h b/src/search.h
index fa0f2e2..a8aaf90 100644
--- a/src/search.h
+++ b/src/search.h
@@ -66,5 +66,6 @@ int ts_string_match(utf8_int8_t *first, utf8_int8_t *second);
ts_search_result* ts_create_empty_search_result();
bool ts_string_contains(utf8_int8_t *text_to_search, utf8_int8_t *text_to_find, ts_array *text_matches);
void ts_start_search(utf8_int8_t *path, utf8_int8_t *filter, utf8_int8_t *query, int thread_count, int max_file_size);
+void ts_destroy_result(ts_search_result* result);
#endif \ No newline at end of file