From f10ebc2df581d27bea60091001a9aba30301c2ea Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 8 Jan 2018 16:52:01 +0000 Subject: [PATCH] database: Unmap all mapped sections when freeing database Signed-off-by: Michael Tremer --- src/database.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/database.c b/src/database.c index 9cf5f32..73d2394 100644 --- a/src/database.c +++ b/src/database.c @@ -266,15 +266,31 @@ LOC_EXPORT struct loc_database* loc_database_ref(struct loc_database* db) { } static void loc_database_free(struct loc_database* db) { + int r; + DEBUG(db->ctx, "Releasing database %p\n", db); // Removing all ASes if (db->as_v0) { - int r = munmap(db->as_v0, db->as_count * sizeof(*db->as_v0)); + r = munmap(db->as_v0, db->as_count * sizeof(*db->as_v0)); if (r) ERROR(db->ctx, "Could not unmap AS section: %s\n", strerror(errno)); } + // Remove mapped network sections + if (db->networks_v0) { + r = munmap(db->networks_v0, db->networks_count * sizeof(*db->networks_v0)); + if (r) + ERROR(db->ctx, "Could not unmap networks section: %s\n", strerror(errno)); + } + + // Remove mapped network nodes section + if (db->network_nodes_v0) { + r = munmap(db->network_nodes_v0, db->network_nodes_count * sizeof(*db->network_nodes_v0)); + if (r) + ERROR(db->ctx, "Could not unmap network nodes section: %s\n", strerror(errno)); + } + loc_stringpool_unref(db->pool); loc_unref(db->ctx); -- 2.39.2