summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/kwsys/DynamicLoader.cxx13
-rw-r--r--Source/kwsys/testDynamicLoader.cxx2
2 files changed, 9 insertions, 6 deletions
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 7755296..fed90ea 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -160,20 +160,21 @@ LibHandle DynamicLoader::OpenLibrary(const char* libname )
{
return 0;
}
- return NSLinkModule(image, libname,
- NSLINKMODULE_OPTION_PRIVATE|NSLINKMODULE_OPTION_BINDNOW);
+ NSModule handle = NSLinkModule(image, libname,
+ NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+ NSDestroyObjectFileImage(image);
+ return handle;
}
//----------------------------------------------------------------------------
int DynamicLoader::CloseLibrary( LibHandle lib)
{
- // 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);
+ // You should use this option instead if your code experience some problems
+ // reported against Panther 10.3.9 (fixed in Tiger 10.4.2 and up)
+ bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE);
return success;
}
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 0eb9be3..b881967 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -68,6 +68,7 @@ int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, i
<< kwsys::DynamicLoader::LastError() << kwsys_ios::endl;
return 1;
}
+#ifndef __APPLE__
int s = kwsys::DynamicLoader::CloseLibrary(l);
if( (r3 && !s) || (!r3 && s) )
{
@@ -75,6 +76,7 @@ int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, i
<< kwsys::DynamicLoader::LastError() << kwsys_ios::endl;
return 1;
}
+#endif
return 0;
}