From 197ba84a82587daac20f1fb1b0da04038e071b8c Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Thu, 14 May 2020 15:26:10 +0300 Subject: [PATCH] Finished DocumentStore.deinit() --- src/document_store.zig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/document_store.zig b/src/document_store.zig index af73839..2ad2256 100644 --- a/src/document_store.zig +++ b/src/document_store.zig @@ -382,7 +382,23 @@ pub fn analysisContext(self: *DocumentStore, handle: *Handle, arena: *std.heap.A } pub fn deinit(self: *DocumentStore) void { - // @TODO: Deinit everything! + var entry_iterator = self.handles.iterator(); + while (entry_iterator.next()) |entry| { + self.allocator.free(entry.value.document.mem); + if (entry.value.document.sane_text) |sane| { + self.allocator.free(sane); + } + + for (entry.value.import_uris.items) |uri| { + self.allocator.free(uri); + } + + entry.value.import_uris.deinit(); + self.allocator.free(entry.key); + } self.handles.deinit(); + if (self.std_uri) |uri| { + self.allocator.free(uri); + } }