diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-06 17:00:33 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-06 17:00:33 +0100 |
| commit | d6ef32981a2402ec7b26c851ef13afd27a5582d8 (patch) | |
| tree | dd46cdb68a9160b81bc7d958a307a9f7bfa8da77 | |
| parent | 6a0f9d68555e0506a6aee42a5e25634196faf5a6 (diff) | |
free old results
| -rw-r--r-- | src/search.cpp | 10 | ||||
| -rw-r--r-- | src/search.h | 1 |
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 |
