Beispiel #1
0
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);
}
Beispiel #2
0
void
objc_disposeClassPair(Class cls)
{
  Class meta;

  if (cls == 0)
    {
      return;
    }
  meta = ((id) cls)->isa;

  if (objc_lookUpClass (class_getName (cls)) == (id)cls)
    {
      fprintf(stderr, "*** ERROR *** function objc_disposeClassPair() called "
	"on registered class pair '%s'\n", class_getName(cls));
      return;
    /*
       The runtime provides no mechanism to remove a class.
       The following code essentially frees the memory used by a class without
       fully removing it ... which obviously tends to cause random crashes
       later on if anything tries to use the class or to traverse data
       structures containing the class.
       Indeed, it's hard to see how this function could ever be made to work
       (what if there are subclasses of the class being removed, or if
       there are instances of the class?) even with changes to the runtime.
      
      // Remove from the runtime system so nothing tries updating the dtable
      // while we are freeing the class.
      objc_mutex_lock(__objc_runtime_mutex);
      safe_remove_from_subclass_list(meta);
      safe_remove_from_subclass_list(cls);
      objc_mutex_unlock(__objc_runtime_mutex);
    */
    }

  // Free the method and ivar lists.
  freeMethodLists(cls);
  freeMethodLists(meta);
  freeIvarLists(cls);

  // Free the class and metaclass
  free(meta);
  free(cls);
}