From: Michael Tremer Date: Mon, 8 Jan 2018 16:52:01 +0000 (+0000) Subject: database: Unmap all mapped sections when freeing database X-Git-Tag: 0.9.0~115 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=f10ebc2df581d27bea60091001a9aba30301c2ea database: Unmap all mapped sections when freeing database Signed-off-by: Michael Tremer --- 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);