diff --git a/library/public/context.h b/library/public/context.h index b4309edee3..7999127a72 100644 --- a/library/public/context.h +++ b/library/public/context.h @@ -64,7 +64,7 @@ class F3D_EXPORT context * For example, `getSymbol("EGL", "eglGetProcAddress")` looks for the symbol * `eglGetProcAddress` in the library `libEGL.so` on Linux. */ - [[nodiscard]] static function getSymbol(const std::string& lib, const std::string& func); + [[nodiscard]] static function getSymbol(std::string_view lib, std::string_view func); /** * An exception that can be thrown when the requested library cannot be loaded. diff --git a/library/src/context.cxx b/library/src/context.cxx index ec8ca2abf2..d918238fcd 100644 --- a/library/src/context.cxx +++ b/library/src/context.cxx @@ -16,7 +16,7 @@ namespace f3d { //---------------------------------------------------------------------------- -context::function context::getSymbol(const std::string& lib, const std::string& func) +context::function context::getSymbol(std::string_view lib, std::string_view func) { std::string libName = vtksys::DynamicLoader::LibPrefix(); libName += lib; @@ -26,16 +26,17 @@ context::function context::getSymbol(const std::string& lib, const std::string& if (!handle) { - throw context::loading_exception("Cannot find " + lib + " library"); + throw context::loading_exception("Cannot find " + std::string(lib) + " library"); } using symbol = context::fptr (*)(const char*); - symbol address = reinterpret_cast(vtksys::DynamicLoader::GetSymbolAddress(handle, func)); + symbol address = + reinterpret_cast(vtksys::DynamicLoader::GetSymbolAddress(handle, func.data())); if (!address) { - throw context::symbol_exception("Cannot find " + func + " symbol"); + throw context::symbol_exception("Cannot find " + std::string(func) + " symbol"); } return address;