mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 22:00:18 +00:00
Shrink all arenas before reloading the new reg profile
This commit is contained in:
parent
2c27fd9b41
commit
6abe6abe93
@ -206,6 +206,7 @@ R_API void r_reg_arena_poke(RReg *reg, const ut8 *buf);
|
||||
R_API ut8 *r_reg_arena_dup(RReg *reg, const ut8 *source);
|
||||
R_API const char *r_reg_cond_to_string(int n);
|
||||
R_API int r_reg_cond_from_string(const char *str);
|
||||
R_API void r_reg_arena_shrink(RReg *reg);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -311,3 +311,16 @@ R_API int r_reg_arena_set_bytes(RReg *reg, const char* str) {
|
||||
free (bin_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API void r_reg_arena_shrink(RReg *reg) {
|
||||
RListIter *iter;
|
||||
RRegArena *a;
|
||||
int i;
|
||||
for (i = 0; i < R_REG_TYPE_LAST; i++) {
|
||||
r_list_foreach (reg->regset[i].pool, iter, a) {
|
||||
free (a->bytes);
|
||||
a->bytes = malloc (1);
|
||||
a->size = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ R_API int r_reg_set_profile_string(RReg *reg, const char *str) {
|
||||
r_reg_arena_pop (reg);
|
||||
// Purge the old registers
|
||||
r_reg_free_internal (reg, true);
|
||||
r_reg_arena_shrink (reg);
|
||||
|
||||
// Cache the profile string
|
||||
reg->reg_profile_str = strdup (str);
|
||||
|
Loading…
Reference in New Issue
Block a user