2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Free a BOOPSI Class
8 #include <proto/exec.h>
11 /*****************************************************************************
14 #include <intuition/classes.h>
15 #include <proto/boopsi.h>
17 AROS_LH1(BOOL
, FreeClass
,
20 AROS_LHA(struct IClass
*, classPtr
, A0
),
23 struct Library
*, BOOPSIBase
, 8, BOOPSI
)
26 Only for class implementatores.
28 Tries to free a class which has been created with MakeClass() in the
29 first place. This will not succeed in all cases: Classes which
30 still have living objects or which are still beeing used by subclasses
31 can't simply be freed. In this case this call will fail.
33 Public classes will always be removed with RemoveClass() no matter
34 if FreeClass() would succeed or not. This gurantees that after the
35 call to FreeClass() no new objects can be created.
37 If you have a pointer to allocated memory in cl_UserData, you must
38 make a copy of that pointer, call FreeClass() and if the call
39 succeeded, you may free the memory. If you don't follow these rules,
40 you might end up with a class which is partially freed.
43 classPtr - The pointer you got from MakeClass().
46 FALSE if the class couldn't be freed at this time. This can happen
47 either if there are still objects from this class or if the class
48 is used a SuperClass of at least another class.
50 TRUE if the class could be freed. You must not use classPtr after
54 *Always* calls RemoveClass().
57 // Free a public class with dynamic memory in cl_UserD
59 int freeMyClass (Class * cl)
61 struct MyPerClassData * mpcd;
63 mpcd = (struct MyPerClassData *)cl->cl_UserData;
67 FreeMem (mpcd, sizeof (struct MyPerClassData));
79 MakeClass(), "Basic Object-Oriented Programming System for Intuition"
80 and "boopsi Class Reference" Dokument.
83 29-10-95 digulla automatically created from
84 intuition_lib.fd and clib/intuition_protos.h
86 *****************************************************************************/
89 AROS_LIBBASE_EXT_DECL(struct Library
*,BOOPSIBase
)
91 /* Make sure no one creates another object from this class. For private
92 classes, this call does nothing. */
93 RemoveClass (classPtr
);
95 if (!classPtr
->cl_SubclassCount
&& !classPtr
->cl_ObjectCount
)
97 classPtr
->cl_Super
->cl_SubclassCount
--;
99 FreeMem (classPtr
, sizeof (Class
));