From fe02e1fc73a4589d25cc13eb811c287950c4b868 Mon Sep 17 00:00:00 2001 From: Mewt R <25155631+MewtR@users.noreply.github.com> Date: Sat, 30 Nov 2024 11:22:12 -0500 Subject: [PATCH] Get rid of the CB_COPY macro ##refactor --- libr/core/libs.c | 21 +-------------------- libr/io/io_plugin.c | 13 ++----------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/libr/core/libs.c b/libr/core/libs.c index 432ac5e68d66f..1876f021afc8a 100644 --- a/libr/core/libs.c +++ b/libr/core/libs.c @@ -19,26 +19,7 @@ return r_ ## x ## _plugin_remove (core->y, hand); \ } -// TODO: deprecate this -#define CB_COPY(x, y) \ - static int __lib_ ## x ## _cb (RLibPlugin *pl, void *user, void *data) { \ - struct r_ ## x ## _plugin_t *hand = (struct r_ ## x ## _plugin_t *)data; \ - struct r_ ## x ## _plugin_t *instance; \ - RCore *core = (RCore *)user; \ - instance = R_NEW (struct r_ ## x ## _plugin_t); \ - memcpy (instance, hand, sizeof (struct r_ ## x ## _plugin_t)); \ - pl->name = strdup (hand->meta.name); \ - r_ ## x ## _plugin_add (core->y, instance); \ - return true; \ - } \ - static int __lib_ ## x ## _dt (RLibPlugin *pl, void *user, void *data) { \ - struct r_ ## x ## _plugin_t *hand = (struct r_ ## x ## _plugin_t *)data; \ - RCore *core = (RCore *)user; \ - free (pl->name); \ - return r_ ## x ## _plugin_remove (core->y, hand); \ - } - -CB_COPY (io, io) +CB (io, io) CB (core, rcmd) CB (debug, dbg) CB (bp, dbg->bp) diff --git a/libr/io/io_plugin.c b/libr/io/io_plugin.c index f962946552460..bac845a5acff3 100644 --- a/libr/io/io_plugin.c +++ b/libr/io/io_plugin.c @@ -22,25 +22,16 @@ R_API bool r_io_plugin_remove(RIO *io, RIOPlugin *plugin) { } R_API bool r_io_plugin_init(RIO *io) { - RIOPlugin *static_plugin; int i; if (!io) { return false; } - io->plugins = ls_newf (free); + io->plugins = ls_newf (NULL); // fine to use NULL here? for (i = 0; io_static_plugins[i]; i++) { if (!io_static_plugins[i]->meta.name) { continue; } - static_plugin = R_NEW0 (RIOPlugin); - if (!static_plugin) { - return false; - } - memcpy (static_plugin, io_static_plugins[i], sizeof (RIOPlugin)); - if (!r_io_plugin_add (io, static_plugin)) { - free (static_plugin); - return false; - } + r_io_plugin_add (io, io_static_plugins[i]); } return true; }