Add r_spaces_purge() (#15428)

This commit is contained in:
Florian Märkl 2019-11-07 12:24:47 +01:00 committed by radare
parent cab7a195ba
commit b18fc9e428
2 changed files with 9 additions and 0 deletions

View File

@ -67,6 +67,8 @@ R_API bool r_spaces_init(RSpaces *sp, const char *name);
R_API void r_spaces_fini(RSpaces *sp);
// Finalize and free an existing RSpaces
R_API void r_spaces_free(RSpaces *sp);
// Delete all spaces
R_API void r_spaces_purge(RSpaces *sp);
// Get the RSpace with the given name
R_API RSpace *r_spaces_get(RSpaces *sp, const char *name);
// Add a new RSpace if one does not already exist, otherwise return the existing one

View File

@ -65,6 +65,13 @@ R_API void r_spaces_fini(RSpaces *sp) {
R_FREE (sp->name);
}
R_API void r_spaces_purge(RSpaces *sp) {
sp->current = NULL;
r_list_purge (sp->spacestack);
r_rbtree_free (sp->spaces, space_node_free);
sp->spaces = NULL;
}
static int name_space_cmp(const void *incoming, const RBNode *rb, void *user) {
const RSpace *s = container_of (rb, const RSpace, rb);
return strcmp (incoming, s->name);