mirror of
https://github.com/darlinghq/darling-libobjc2.git
synced 2025-03-03 06:06:05 +00:00
Dtable cleanup cleanups.
This commit is contained in:
parent
f5f0816777
commit
7b49755964
@ -234,8 +234,7 @@ static void deallocHiddenClass(id obj, SEL _cmd)
|
||||
struct reference_list *list = object_getIndexedIvars(hiddenClass);
|
||||
cleanupReferenceList(list);
|
||||
|
||||
// FIXME: Low memory profile.
|
||||
SparseArrayDestroy(hiddenClass->dtable);
|
||||
free_dtable(hiddenClass->dtable);
|
||||
|
||||
// Free the class
|
||||
free(hiddenClass);
|
||||
|
15
dtable.c
15
dtable.c
@ -268,6 +268,16 @@ PRIVATE dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
|
||||
return dtable;
|
||||
}
|
||||
|
||||
PRIVATE void free_dtable(dtable_t dtable)
|
||||
{
|
||||
if (NULL != dtable->slots)
|
||||
{
|
||||
free(dtable->slots);
|
||||
}
|
||||
DESTROY_LOCK(dtable->lock);
|
||||
free(dtable);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@ -495,6 +505,11 @@ PRIVATE dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls)
|
||||
return SparseArrayCopy(old);
|
||||
}
|
||||
|
||||
PRIVATE void free_dtable(dtable_t dtable)
|
||||
{
|
||||
SparseArrayDestroy(dtable);
|
||||
}
|
||||
|
||||
#endif // __OBJC_LOW_MEMORY__
|
||||
|
||||
LEGACY void update_dispatch_table_for_class(Class cls)
|
||||
|
4
dtable.h
4
dtable.h
@ -123,6 +123,6 @@ void add_method_list_to_class(Class cls,
|
||||
struct objc_method_list *list);
|
||||
|
||||
/**
|
||||
* Creates a copy of the class's dispatch table.
|
||||
* Destroys a dtable.
|
||||
*/
|
||||
dtable_t objc_copy_dtable_for_class(dtable_t old, Class cls);
|
||||
void free_dtable(dtable_t dtable);
|
||||
|
@ -138,7 +138,7 @@ BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types)
|
||||
|
||||
if (objc_test_class_flag(cls, objc_class_flag_resolved))
|
||||
{
|
||||
objc_update_dtable_for_class(cls);
|
||||
add_method_list_to_class(cls, methods);
|
||||
}
|
||||
|
||||
return YES;
|
||||
@ -569,6 +569,8 @@ void objc_disposeClassPair(Class cls)
|
||||
freeMethodLists(cls);
|
||||
freeMethodLists(meta);
|
||||
freeIvarLists(cls);
|
||||
free_dtable(cls->dtable);
|
||||
free_dtable(meta->dtable);
|
||||
|
||||
// Free the class and metaclass
|
||||
free(meta);
|
||||
|
Loading…
x
Reference in New Issue
Block a user