Merge branch 'master' into noglib

This commit is contained in:
Nguyen Anh Quynh 2016-12-22 12:13:34 +08:00
commit 93044e39f1
2 changed files with 11 additions and 10 deletions

View File

@ -279,6 +279,7 @@ dist:
git archive --format=zip --prefix=unicorn-$(DIST_VERSION)/ $(TAG) > unicorn-$(DIST_VERSION).zip
# run "make header" whenever qemu/header_gen.py is modified
header:
$(eval TARGETS := m68k arm aarch64 mips mipsel mips64 mips64el\
powerpc sparc sparc64 x86_64)

20
uc.c
View File

@ -1069,19 +1069,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 = 0;
int i;
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);
}
// we can't dereference hook->type if hook is invalid
// so for now we need to iterate over all possible types to remove the hook
// which is less efficient
// an optimization would be to align the hook pointer
// and store the type mask in the hook pointer.
for (i = 0; i < UC_HOOK_MAX; i++) {
if (list_remove(&uc->hook[i], (void *)hook)) {
if (--hook->refs == 0) {
free(hook);
}
}
i++;
}
return UC_ERR_OK;
}