changeset 24663:ca416267c65f

oct-shlib: move common property to base class. * oct-shlib.cc, oct-shlib.h: Move property "search_all_loaded" that was defined separately in each child class to the base class "dynlib_rep".
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 01 Feb 2018 17:49:32 +0100
parents 276eca875721
children a829062fdea4
files liboctave/util/oct-shlib.cc liboctave/util/oct-shlib.h
diffstat 2 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/oct-shlib.cc	Wed Jan 31 17:24:05 2018 -0800
+++ b/liboctave/util/oct-shlib.cc	Thu Feb 01 17:49:32 2018 +0100
@@ -190,13 +190,10 @@
   private:
 
     void *library;
-
-    bool search_all_loaded;
   };
 
   octave_dlopen_shlib::octave_dlopen_shlib (const std::string& f)
-    : dynamic_library::dynlib_rep (f), library (nullptr),
-      search_all_loaded (false)
+    : dynamic_library::dynlib_rep (f), library (nullptr)
   {
     int flags = 0;
 
@@ -289,8 +286,6 @@
   private:
 
     shl_t library;
-
-    bool search_all_loaded;
   };
 
   octave_shl_load_shlib::octave_shl_load_shlib (const std::string& f)
@@ -382,7 +377,7 @@
   }
 
   octave_w32_shlib::octave_w32_shlib (const std::string& f)
-    : dynamic_library::dynlib_rep (f), handle (0), search_all_loaded (false)
+    : dynamic_library::dynlib_rep (f), handle (0)
   {
     if (f.empty())
       {
@@ -464,7 +459,7 @@
 
      if (got_libs)
       {
-        for (int i = 0; i < (bytes_all_libs / size_lib); i++)
+        for (size_t i = 0; i < (bytes_all_libs / size_lib); i++)
           {
               // Check for function in library.
               function = reinterpret_cast<void *>
@@ -487,7 +482,7 @@
   {
     void *function = nullptr;
 
-    if (! is_open ())
+    if (! search_all_loaded && ! is_open ())
       (*current_liboctave_error_handler)
         ("shared library %s is not open", file.c_str ());
 
@@ -535,8 +530,6 @@
 
     NSObjectFileImage img;
     NSModule handle;
-
-    bool search_all_loaded;
   };
 
   octave_dyld_shlib::octave_dyld_shlib (const std::string& f)
--- a/liboctave/util/oct-shlib.h	Wed Jan 31 17:24:05 2018 -0800
+++ b/liboctave/util/oct-shlib.h	Thu Feb 01 17:49:32 2018 +0100
@@ -48,7 +48,9 @@
     public:
 
       dynlib_rep (void)
-        : count (1), file (), tm_loaded (time_t ()), fcn_names () { }
+        : count (1), search_all_loaded (false), file (), tm_loaded (time_t ()),
+          fcn_names ()
+      { }
 
     protected:
 
@@ -93,6 +95,7 @@
     public:
 
       refcount<int> count;
+      bool search_all_loaded;
 
     protected: