[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'Intuition' (#aros)


Frees a boopsi class created by MakeClass().


Source position: intuition.pas line 3307

function FreeClass(

  IClass: PIClass


Function result

Returns False if the class could not be freed. Reasons include, but will not be limited to, having non-zero cl_ObjectCount or cl_SubclassCount. Returns True if the class could be freed. Calls RemoveClass() for the class in either case.


For class implementors only.

Tries to free a boopsi class created by MakeClass(). This won't always succeed: classes with outstanding objects or with subclasses cannot be freed. You cannot allow the code which implements the class to be unloaded in this case.

For public classes, this function will always remove the class (see RemoveClass() ) making it unavailable, whether it succeeds or not.

If you have a dynamically allocated data for your class (hanging off of cl_UserData), try to free the class before you free the user data, so you don't get stuck with a half-freed class.


// Free a public class with dynamic memory in cl_UserData
function freeMyClass(cl: PClass): Boolean;
  mpcd: PMyPerClassData;
  Result := False;
  mpcd = PMyPerClassData(cl^.cl_UserData);
  if FreeClass(cl) then
    FreeMem(mpcd, SizeOf(TMyPerClassData));
    Result := True;

See also



Create and initialize a boopsi class.

Documentation generated on: 2017-01-10