mirror of
https://protopirate.net/ProtoPirate/ProtoPirate.git
synced 2026-10-06 16:37:15 +00:00
Free API resolvers after plugin loads, not on plugin unload
* This allows us to remove a few plugin_resolver pointers from the ProtoPirateApp struct too. * The resolvers were never used, and arent required to unload or run the plugin. * No change to app, but this frees a bit more RAM
This commit is contained in:
@@ -66,11 +66,6 @@ void protopirate_unload_protocol_plugin(ProtoPirateTxRx* txrx) {
|
||||
plugin_manager_free(txrx->protocol_plugin_manager);
|
||||
txrx->protocol_plugin_manager = NULL;
|
||||
}
|
||||
|
||||
if(txrx->plugin_resolver) {
|
||||
composite_api_resolver_free(txrx->plugin_resolver);
|
||||
txrx->plugin_resolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static bool protopirate_ensure_protocol_registry_plugin(
|
||||
@@ -95,8 +90,7 @@ static bool protopirate_ensure_protocol_registry_plugin(
|
||||
return true;
|
||||
}
|
||||
|
||||
if(app->txrx->protocol_plugin || app->txrx->protocol_plugin_manager ||
|
||||
app->txrx->plugin_resolver) {
|
||||
if(app->txrx->protocol_plugin || app->txrx->protocol_plugin_manager) {
|
||||
protopirate_unload_protocol_plugin(app->txrx);
|
||||
}
|
||||
|
||||
@@ -154,11 +148,10 @@ static bool protopirate_ensure_protocol_registry_plugin(
|
||||
plugin->release();
|
||||
}
|
||||
plugin_manager_free(manager);
|
||||
composite_api_resolver_free(resolver);
|
||||
return false;
|
||||
}
|
||||
|
||||
app->txrx->plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->txrx->protocol_plugin_manager = manager;
|
||||
app->txrx->protocol_plugin = plugin;
|
||||
app->txrx->protocol_registry_route = route;
|
||||
@@ -205,8 +198,7 @@ static bool protopirate_ensure_tx_protocol_plugin(
|
||||
return true;
|
||||
}
|
||||
|
||||
if(app->txrx->protocol_plugin || app->txrx->protocol_plugin_manager ||
|
||||
app->txrx->plugin_resolver) {
|
||||
if(app->txrx->protocol_plugin || app->txrx->protocol_plugin_manager) {
|
||||
protopirate_unload_protocol_plugin(app->txrx);
|
||||
}
|
||||
|
||||
@@ -260,7 +252,7 @@ static bool protopirate_ensure_tx_protocol_plugin(
|
||||
return false;
|
||||
}
|
||||
|
||||
app->txrx->plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->txrx->protocol_plugin_manager = manager;
|
||||
app->txrx->protocol_plugin = plugin;
|
||||
*registry = plugin->registry;
|
||||
|
||||
@@ -124,11 +124,6 @@ static void psa_bf_plugin_unload(ProtoPirateApp* app) {
|
||||
plugin_manager_free(app->psa_bf_plugin_manager);
|
||||
app->psa_bf_plugin_manager = NULL;
|
||||
}
|
||||
|
||||
if(app->psa_bf_plugin_resolver) {
|
||||
composite_api_resolver_free(app->psa_bf_plugin_resolver);
|
||||
app->psa_bf_plugin_resolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool protopirate_psa_bf_plugin_ensure_loaded(ProtoPirateApp* app) {
|
||||
@@ -136,7 +131,7 @@ bool protopirate_psa_bf_plugin_ensure_loaded(ProtoPirateApp* app) {
|
||||
|
||||
if(app->psa_bf_plugin) return true;
|
||||
|
||||
if(app->psa_bf_plugin_manager || app->psa_bf_plugin_resolver) {
|
||||
if(app->psa_bf_plugin_manager) {
|
||||
psa_bf_plugin_unload(app);
|
||||
}
|
||||
|
||||
@@ -173,7 +168,7 @@ bool protopirate_psa_bf_plugin_ensure_loaded(ProtoPirateApp* app) {
|
||||
return false;
|
||||
}
|
||||
|
||||
app->psa_bf_plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->psa_bf_plugin_manager = manager;
|
||||
app->psa_bf_plugin = plugin;
|
||||
plugin->set_host_api(&protopirate_psa_bf_host_api);
|
||||
|
||||
@@ -203,8 +203,7 @@ void protopirate_radio_deinit(ProtoPirateApp* app) {
|
||||
bool has_radio_resources = app->radio_initialized || app->txrx->worker ||
|
||||
app->txrx->environment || app->txrx->receiver ||
|
||||
app->txrx->history || app->txrx->radio_device ||
|
||||
app->txrx->protocol_plugin_manager || app->txrx->plugin_resolver ||
|
||||
app->txrx->protocol_plugin;
|
||||
app->txrx->protocol_plugin_manager || app->txrx->protocol_plugin;
|
||||
if(!has_radio_resources) {
|
||||
#ifndef REMOVE_LOGS
|
||||
FURI_LOG_D(TAG, "Radio resources were not initialized, returning");
|
||||
|
||||
@@ -140,11 +140,6 @@ static void protopirate_tool_scene_plugin_unload(ProtoPirateApp* app) {
|
||||
plugin_manager_free(app->tool_scene_plugin_manager);
|
||||
app->tool_scene_plugin_manager = NULL;
|
||||
}
|
||||
|
||||
if(app->tool_scene_plugin_resolver) {
|
||||
composite_api_resolver_free(app->tool_scene_plugin_resolver);
|
||||
app->tool_scene_plugin_resolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static bool protopirate_tool_scene_plugin_ensure_loaded(
|
||||
@@ -203,7 +198,7 @@ static bool protopirate_tool_scene_plugin_ensure_loaded(
|
||||
return false;
|
||||
}
|
||||
|
||||
app->tool_scene_plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->tool_scene_plugin_manager = manager;
|
||||
app->tool_scene_plugin = plugin;
|
||||
app->tool_scene_plugin_kind = kind;
|
||||
|
||||
+2
-7
@@ -30,11 +30,6 @@ void shared_plugin_unload(ProtoPirateApp* app, ProtoPirateSharedPlugin plugin_ty
|
||||
plugin_manager_free(app->plugin_manager);
|
||||
app->plugin_manager = NULL;
|
||||
}
|
||||
|
||||
if(app->plugin_resolver) {
|
||||
composite_api_resolver_free(app->plugin_resolver);
|
||||
app->plugin_resolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool shared_plugin_load(ProtoPirateApp* app, ProtoPirateSharedPlugin plugin_type) {
|
||||
@@ -48,7 +43,7 @@ bool shared_plugin_load(ProtoPirateApp* app, ProtoPirateSharedPlugin plugin_type
|
||||
if(app->about_plugin) return true;
|
||||
}
|
||||
|
||||
if(app->plugin_manager || app->plugin_resolver) {
|
||||
if(app->plugin_manager) {
|
||||
shared_plugin_unload(app, plugin_type);
|
||||
}
|
||||
|
||||
@@ -122,7 +117,7 @@ bool shared_plugin_load(ProtoPirateApp* app, ProtoPirateSharedPlugin plugin_type
|
||||
app->about_plugin = plugin_about;
|
||||
}
|
||||
|
||||
app->plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->plugin_manager = manager;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ typedef struct ProtoPirateTxRx {
|
||||
SubGhzReceiver* receiver;
|
||||
SubGhzRadioPreset* preset;
|
||||
const SubGhzProtocolRegistry* protocol_registry;
|
||||
CompositeApiResolver* plugin_resolver;
|
||||
PluginManager* protocol_plugin_manager;
|
||||
const ProtoPirateProtocolPlugin* protocol_plugin;
|
||||
ProtoPirateProtocolRegistryRoute protocol_registry_route;
|
||||
@@ -105,7 +104,6 @@ struct ProtoPirateApp {
|
||||
char save_filename[64];
|
||||
FuriString* save_protocol;
|
||||
uint16_t save_history_idx;
|
||||
CompositeApiResolver* plugin_resolver;
|
||||
PluginManager* plugin_manager;
|
||||
#ifdef ENABLE_EMULATE_FEATURE
|
||||
#define EMULATE_NAV_NONE 0U
|
||||
@@ -117,10 +115,8 @@ struct ProtoPirateApp {
|
||||
const ProtoPirateConfigPlugin* config_plugin;
|
||||
const ProtoPirateSavedInfoPlugin* saved_info_plugin;
|
||||
const ProtoPirateAboutPlugin* about_plugin;
|
||||
CompositeApiResolver* psa_bf_plugin_resolver;
|
||||
PluginManager* psa_bf_plugin_manager;
|
||||
const ProtoPiratePsaBfPlugin* psa_bf_plugin;
|
||||
CompositeApiResolver* tool_scene_plugin_resolver;
|
||||
PluginManager* tool_scene_plugin_manager;
|
||||
const ProtoPirateToolScenePlugin* tool_scene_plugin;
|
||||
ProtoPirateToolScenePluginKind tool_scene_plugin_kind;
|
||||
|
||||
@@ -98,11 +98,6 @@ static void emulate_plugin_unload(ProtoPirateApp* app) {
|
||||
plugin_manager_free(app->plugin_manager);
|
||||
app->plugin_manager = NULL;
|
||||
}
|
||||
|
||||
if(app->plugin_resolver) {
|
||||
composite_api_resolver_free(app->plugin_resolver);
|
||||
app->plugin_resolver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static bool emulate_plugin_load(ProtoPirateApp* app) {
|
||||
@@ -110,7 +105,7 @@ static bool emulate_plugin_load(ProtoPirateApp* app) {
|
||||
|
||||
if(app->emulate_plugin) return true;
|
||||
|
||||
if(app->plugin_manager || app->plugin_resolver) {
|
||||
if(app->plugin_manager) {
|
||||
emulate_plugin_unload(app);
|
||||
}
|
||||
|
||||
@@ -148,7 +143,7 @@ static bool emulate_plugin_load(ProtoPirateApp* app) {
|
||||
return false;
|
||||
}
|
||||
|
||||
app->plugin_resolver = resolver;
|
||||
composite_api_resolver_free(resolver);
|
||||
app->plugin_manager = manager;
|
||||
app->emulate_plugin = plugin;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user