void objc_disposeClassPair(Class cls) { if (0 == cls) { return; } Class meta = ((id)cls)->isa; // Remove from the runtime system so nothing tries updating the dtable // while we are freeing the class. { LOCK_RUNTIME_FOR_SCOPE(); safe_remove_from_subclass_list(meta); safe_remove_from_subclass_list(cls); } // Free the method and ivar lists. freeMethodLists(cls); freeMethodLists(meta); freeIvarLists(cls); if (cls->dtable != uninstalled_dtable) { free_dtable(cls->dtable); } if (meta->dtable != uninstalled_dtable) { free_dtable(meta->dtable); } // Free the class and metaclass gc->free(meta); gc->free(cls); }
void objc_registerProtocol(Protocol *proto) { if (NULL == proto) { return; } LOCK_RUNTIME_FOR_SCOPE(); if (objc_getProtocol(proto->name) != NULL) { return; } if (nil != proto->isa) { return; } proto->isa = ObjC2ProtocolClass; protocol_table_insert((struct objc_protocol2*)proto); }
PRIVATE void objc_collect_garbage_data(void(*cleanup)(void*), void *garbage) { if (0 == garbage_queue) { LOCK_RUNTIME_FOR_SCOPE(); if (0 == garbage_queue) { garbage_queue = dispatch_queue_create("ObjC deferred free queue", 0); } } dispatch_async_f(garbage_queue, garbage, cleanup); }
void objc_registerClassPair(Class cls) { LOCK_RUNTIME_FOR_SCOPE(); class_table_insert(cls); objc_resolve_class(cls); }