From a4decfa4e34cd27396800ca40de5e729acf160c1 Mon Sep 17 00:00:00 2001 From: theraven Date: Mon, 23 May 2011 17:38:31 +0000 Subject: [PATCH] Add hidden class -dealloc method as -finalize as well. --- associate.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/associate.m b/associate.m index 3c6767b..7ec103a 100644 --- a/associate.m +++ b/associate.m @@ -231,6 +231,8 @@ static inline Class initHiddenClassForObject(id obj) SELECTOR(dealloc))); class_addMethod(hiddenClass, SELECTOR(dealloc), (IMP)deallocHiddenClass, types); + class_addMethod(hiddenClass, SELECTOR(finalize), (IMP)deallocHiddenClass, + types); obj->isa = hiddenClass; } return hiddenClass; @@ -243,7 +245,7 @@ static void deallocHiddenClass(id obj, SEL _cmd) // Call the real -dealloc method (this ordering is required in case the // user does @synchronized(self) in -dealloc) struct objc_super super = {obj, realClass}; - objc_msg_lookup_super(&super, SELECTOR(dealloc))(obj, SELECTOR(dealloc)); + objc_msg_lookup_super(&super, _cmd)(obj, _cmd); // After calling [super dealloc], the object will no longer exist. // Free the hidden struct reference_list *list = object_getIndexedIvars(hiddenClass);