diff options
Diffstat (limited to 'src/instance.c')
-rw-r--r-- | src/instance.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/src/instance.c b/src/instance.c index f05cc86..2563bf6 100644 --- a/src/instance.c +++ b/src/instance.c @@ -143,25 +143,8 @@ open_wrapper(SuilHost* host, return NULL; } - const char* const env_dir = getenv("SUIL_MODULE_DIR"); - const char* const mod_dir = env_dir ? env_dir : SUIL_MODULE_DIR; - - const size_t path_len = strlen(mod_dir) - + strlen(SUIL_DIR_SEP SUIL_MODULE_PREFIX SUIL_MODULE_EXT) - + strlen(module_name) - + 2; - - char* const path = (char*)calloc(path_len, 1); - snprintf(path, path_len, "%s%s%s%s%s", - mod_dir, SUIL_DIR_SEP, - SUIL_MODULE_PREFIX, module_name, SUIL_MODULE_EXT); - - // Open wrap module - dlerror(); - void* lib = dlopen(path, RTLD_NOW); + void* const lib = suil_open_module(module_name); if (!lib) { - SUIL_ERRORF("Unable to open wrap module %s (%s)\n", path, dlerror()); - free(path); return NULL; } @@ -176,17 +159,13 @@ open_wrapper(SuilHost* host, n_features) : NULL; - if (!wrapper) { - SUIL_ERRORF("Corrupt module %s\n", path); + if (wrapper) { + wrapper->lib = lib; + } else { + SUIL_ERRORF("Corrupt wrap module %s\n", module_name); dlclose(lib); - free(path); - return NULL; } - free(path); - - wrapper->lib = lib; - return wrapper; } |