Skip to content

Commit

Permalink
Reintroduce RBinPlugin->{init/fini} for plugins that need to initiali…
Browse files Browse the repository at this point in the history
…ze a third party global runtime ##bin
  • Loading branch information
condret committed Oct 18, 2023
1 parent 913d03b commit e32a370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libr/bin/bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ R_IPI RBinXtrPlugin *r_bin_get_xtrplugin_by_name(RBin *bin, const char *name) {
}

static void r_bin_plugin_free(RBinPlugin *p) {
if (p && p->fini) {
p->fini ();
}
R_FREE (p);
}

Expand All @@ -425,6 +428,9 @@ R_API bool r_bin_plugin_add(RBin *bin, RBinPlugin *foo) {
RBinPlugin *plugin;

r_return_val_if_fail (bin && foo, false);
if (foo->init) {
foo->init (bin);
}

r_list_foreach (bin->plugins, it, plugin) {
if (!strcmp (plugin->meta.name, foo->meta.name)) {
Expand Down
2 changes: 2 additions & 0 deletions libr/include/r_bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ R_API void r_bin_trycatch_free(RBinTrycatch *tc);

typedef struct r_bin_plugin_t {
RPluginMeta meta;
void (*init)(RBin *bin);
void (*fini)();
Sdb * (*get_sdb)(RBinFile *obj);
bool (*load)(RBinFile *bf, RBuffer *buf, ut64 laddr);
ut64 (*size)(RBinFile *bin); // return ut64 maybe? meh
Expand Down

0 comments on commit e32a370

Please sign in to comment.