From 7f5222d400ab7f2d95099933abeee769bc23b38c Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Mon, 13 Mar 2006 11:27:12 -0500 Subject: [PATCH] ENH: Fix dashboard with coverage --- Source/kwsys/DynamicLoader.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 887f5aba7..77552960e 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -167,7 +167,13 @@ LibHandle DynamicLoader::OpenLibrary(const char* libname ) //---------------------------------------------------------------------------- int DynamicLoader::CloseLibrary( LibHandle lib) { - bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE); + // Initially this function was written using NSUNLINKMODULE_OPTION_NONE, but when + // the code is compiled with coverage on, one cannot close the library properly + // so instead of not unloading the library. We use a special option: + // NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED + // With this option the memory for the module is not deallocated + // allowing pointers into the module to still be valid. + bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED); return success; }