From 25a367862dbdfb0fdfdfc6f619af3f0a7e0fe79f Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 30 Jun 2025 15:29:44 -0700 Subject: Use nullptr --- plugin/src/plugin.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'plugin/src') diff --git a/plugin/src/plugin.c b/plugin/src/plugin.c index e2aae1f..3a0ef5d 100644 --- a/plugin/src/plugin.c +++ b/plugin/src/plugin.c @@ -64,14 +64,14 @@ static bool load_library(Plugin* plugin) { // Handle reloading a previously-loaded library. if (plugin->handle) { dlclose(plugin->handle); - plugin->handle = 0; + plugin->handle = nullptr; } const mstring lib = plugin_lib_path(plugin); // If the plugin fails to load, make sure to keep the plugin's old handle to // handle the error gracefully. This handles reload failures, specifically. - void* handle = 0; + void* handle = nullptr; if ((handle = dlopen(mstring_cstr(&lib), RTLD_NOW))) { LOGD("Plugin [%s] loaded successfully", mstring_cstr(&plugin->filename)); plugin->handle = handle; @@ -86,7 +86,7 @@ static bool load_library(Plugin* plugin) { static void delete_plugin_state(Plugin* plugin) { if (plugin->state) { free(plugin->state); - plugin->state = 0; + plugin->state = nullptr; } } @@ -105,7 +105,7 @@ static void destroy_plugin(Plugin* plugin) { if (plugin) { if (plugin->handle) { dlclose(plugin->handle); - plugin->handle = 0; + plugin->handle = nullptr; } delete_plugin_state(plugin); } @@ -118,7 +118,7 @@ Plugin* load_plugin(PluginEngine* eng, const char* filename) { Plugin plugin = (Plugin){.eng = eng, .filename = mstring_make(filename)}; if (!load_library(&plugin)) { - return 0; + return nullptr; } list_add(eng->plugins, plugin); @@ -132,7 +132,7 @@ void delete_plugin(Plugin** pPlugin) { assert(plugin->eng); destroy_plugin(plugin); list_remove_ptr(plugin->eng->plugins, plugin); - *pPlugin = 0; + *pPlugin = nullptr; } } @@ -148,7 +148,7 @@ bool plugin_reloaded(Plugin* plugin) { // ----------------------------------------------------------------------------- PluginEngine* new_plugin_engine(const PluginEngineDesc* desc) { - PluginEngine* eng = 0; + PluginEngine* eng = nullptr; if (!(eng = calloc(1, sizeof(PluginEngine)))) { goto cleanup; @@ -173,7 +173,7 @@ PluginEngine* new_plugin_engine(const PluginEngineDesc* desc) { cleanup: delete_plugin_engine(&eng); - return 0; + return nullptr; } void delete_plugin_engine(PluginEngine** pEng) { @@ -191,7 +191,7 @@ void delete_plugin_engine(PluginEngine** pEng) { close(eng->inotify_instance); } free(eng); - *pEng = 0; + *pEng = nullptr; } } -- cgit v1.2.3