From 464c9398ae49d8faae46f81fb7040155408858f7 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 30 Aug 2023 23:18:38 +0100 Subject: Perform very minor load/unload optimisations Because why not. --- src/sst.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/sst.c') diff --git a/src/sst.c b/src/sst.c index 3618210..6b03acf 100644 --- a/src/sst.c +++ b/src/sst.c @@ -250,6 +250,7 @@ static const char *updatenotes = "\ #include // generated by build/codegen.c static void do_featureinit(void) { + engineapi_lateinit(); // load libs that might not be there early (...at least on Linux???) clientlib = os_dlhandle(OS_LIT("client") OS_LIT(OS_DLSUFFIX)); if (!clientlib) { @@ -410,22 +411,19 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) { } static void do_unload(void) { -#ifdef _WIN32 // this is only relevant in builds that predate linux support - if (pluginhandler) { // if not, oh well too bad :^) + if (sst_userunloaded) { // note: pluginhandler must also be set here cmd_plugin_load->cb = orig_plugin_load_cb; cmd_plugin_unload->cb = orig_plugin_unload_cb; - if (sst_userunloaded) { - struct CPlugin **plugins = pluginhandler->plugins.m.mem; - // see comment in CPlugin above. setting this to the real handle - // right before the engine tries to unload us allows it to actually - // do so. in newer branches this is redundant but doesn't do any - // harm so it's just unconditional. NOTE: old engines ALSO just leak - // the handle and never call Unload() if Load() fails; can't really - // do anything about that. - plugins[ownidx]->module = ownhandle(); - } - } +#ifdef _WIN32 // this bit is only relevant in builds that predate linux support + struct CPlugin **plugins = pluginhandler->plugins.m.mem; + // see comment in CPlugin above. setting this to the real handle right + // before the engine tries to unload us allows it to actually do so. in + // newer branches this is redundant but doesn't do any harm so it's just + // unconditional. NOTE: old engines ALSO just leak the handle and never + // call Unload() if Load() fails; can't really do anything about that. + plugins[ownidx]->module = ownhandle(); #endif + } endfeatures(); con_disconnect(); } -- cgit v1.2.3