mirror of
https://github.com/Vita3K/unicorn.git
synced 2024-11-23 21:39:44 +00:00
more efficient hook removal
This commit is contained in:
parent
8c58da4416
commit
d5e85cf3f9
18
uc.c
18
uc.c
@ -1029,15 +1029,19 @@ uc_err uc_hook_add(uc_engine *uc, uc_hook *hh, int type, void *callback,
|
||||
UNICORN_EXPORT
|
||||
uc_err uc_hook_del(uc_engine *uc, uc_hook hh)
|
||||
{
|
||||
int i;
|
||||
struct hook *hook;
|
||||
for (i = 0; i < UC_HOOK_MAX; i++) {
|
||||
if (list_remove(&uc->hook[i], (void *)hh)) {
|
||||
hook = (struct hook *)hh;
|
||||
if (--hook->refs == 0) {
|
||||
free(hook);
|
||||
int i = 0;
|
||||
struct hook *hook = (struct hook *)hh;
|
||||
int type = hook->type;
|
||||
|
||||
while ((type >> i) > 0 && i < UC_HOOK_MAX) {
|
||||
if ((type >> i) & 1) {
|
||||
if (list_remove(&uc->hook[i], (void *)hh)) {
|
||||
if (--hook->refs == 0) {
|
||||
free(hook);
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return UC_ERR_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user