mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
Adding cmd deinit to core and cmd_api
This commit is contained in:
parent
69921cd65b
commit
3c3443fc2b
@ -31,6 +31,8 @@ R_API RCmd *r_cmd_free(RCmd *cmd) {
|
||||
int i;
|
||||
if (!cmd) return NULL;
|
||||
r_cmd_alias_free (cmd);
|
||||
// dinitialize plugin commands
|
||||
r_core_plugin_deinit(cmd);
|
||||
r_list_free (cmd->plist);
|
||||
r_list_free (cmd->lcmds);
|
||||
for (i=0;i<NCMDS;i++)
|
||||
|
@ -670,7 +670,7 @@ static char * r_cmd_replace_name (const char *s_new, ut32 replace_len, const cha
|
||||
*res_len = 0;
|
||||
if (num_occurences > 0 && replace_len > 0 && s_old) {
|
||||
ut32 consumed = 0;
|
||||
char * next = r_cmd_get_next_classname_str (buffer+consumed, s_old);
|
||||
const char * next = r_cmd_get_next_classname_str (buffer+consumed, s_old);
|
||||
IFDBG r_cons_printf ("Replacing \"%s\" with \"%s\" in: %s\n", s_old, s_new, buffer);
|
||||
result = malloc (num_occurences*replace_len + buf_len);
|
||||
memset (result, 0, num_occurences*replace_len + buf_len);
|
||||
@ -710,7 +710,8 @@ static int r_cmd_java_get_class_names_from_input (const char *input, char **clas
|
||||
else if (!new_class_name || *new_class_name) return res;
|
||||
else if (!new_class_name_len || !class_name_len) return res;
|
||||
|
||||
*new_class_name = *class_name_len = NULL;
|
||||
*new_class_name = NULL;
|
||||
*class_name_len = 0;
|
||||
|
||||
if (p && *p && cmd_sz > 1) {
|
||||
const char *end = p;
|
||||
@ -1901,6 +1902,8 @@ RCorePlugin r_core_plugin_java = {
|
||||
.desc = "Suite of java commands, java help for more info",
|
||||
.license = "Apache",
|
||||
.call = r_cmd_java_call,
|
||||
.deinit = NULL,
|
||||
.init = NULL,
|
||||
};
|
||||
|
||||
#ifndef CORELIB
|
||||
|
@ -10,6 +10,17 @@
|
||||
|
||||
static RCorePlugin *cmd_static_plugins[] = { R_CORE_STATIC_PLUGINS };
|
||||
|
||||
R_API int r_core_plugin_deinit(RCmd *cmd) {
|
||||
RListIter *iter;
|
||||
RCorePlugin *plugin;
|
||||
r_list_foreach (cmd->plist, iter, plugin) {
|
||||
if (plugin && plugin->deinit) {
|
||||
plugin->deinit (NULL, NULL);
|
||||
}
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_core_plugin_add(RCmd *cmd, RCorePlugin *plugin) {
|
||||
if (plugin->init)
|
||||
if (!plugin->init (cmd, NULL))
|
||||
@ -21,7 +32,7 @@ R_API int r_core_plugin_add(RCmd *cmd, RCorePlugin *plugin) {
|
||||
R_API int r_core_plugin_init(RCmd *cmd) {
|
||||
int i;
|
||||
RCorePlugin *static_plugin;
|
||||
cmd->plist = r_list_newf (NULL);
|
||||
cmd->plist = r_list_newf (r_core_plugin_deinit);
|
||||
for (i=0; cmd_static_plugins[i]; i++) {
|
||||
if (!r_core_plugin_add (cmd, cmd_static_plugins[i])) {
|
||||
eprintf ("Error loading cmd plugin\n");
|
||||
|
@ -82,12 +82,14 @@ typedef struct r_core_plugin_t {
|
||||
const char *license;
|
||||
RCmdCallback call;
|
||||
RCmdCallback init;
|
||||
RCmdCallback deinit;
|
||||
} RCorePlugin;
|
||||
|
||||
#ifdef R_API
|
||||
R_API int r_core_plugin_init(RCmd *cmd);
|
||||
R_API int r_core_plugin_add(RCmd *cmd, RCorePlugin *plugin);
|
||||
R_API int r_core_plugin_check(RCmd *cmd, const char *a0);
|
||||
R_API int r_core_plugin_deinit(RCmd *cmd);
|
||||
|
||||
/* review api */
|
||||
R_API RCmd *r_cmd_new();
|
||||
|
Loading…
Reference in New Issue
Block a user