aome further corrections to copyright notices.
[AROS.git] / workbench / libs / muimaster / mui_freeclass.c
blob6eac1e93bb2286b15bc0427da2e245b74c225824
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <string.h>
8 #include <proto/muimaster.h>
9 #include <proto/intuition.h>
10 #include <proto/exec.h>
12 #include "muimaster_intern.h"
13 #include "support_classes.h"
14 #include "debug.h"
16 /*****************************************************************************
18 NAME */
19 AROS_LH1(VOID, MUI_FreeClass,
21 /* SYNOPSIS */
22 AROS_LHA(Class *, cl, A0),
24 /* LOCATION */
25 struct Library *, MUIMasterBase, 14, MUIMaster)
27 /* FUNCTION
28 Frees a class returned by MUI_GetClass(). This function is
29 obsolete. Use MUI_DeleteCustomClass() instead.
31 INPUTS
32 cl - The pointer to the class.
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 MUI_GetClass(), MUI_CreateCustomClass(), MUI_DeleteCustomClass()
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 ObtainSemaphore(&MUIMB(MUIMasterBase)->ZuneSemaphore);
53 /* CLF_INLIST tells us that this class is a builtin class */
54 if (cl->cl_Flags & CLF_INLIST)
56 Class *super = cl->cl_Super;
57 char *count = (char *)cl->cl_Dispatcher.h_Data;
59 if (--count == 0)
61 ZUNE_RemoveBuiltinClass(cl, MUIMasterBase);
63 if (FreeClass(cl))
65 CloseLibrary(MUIMasterBase);
66 if (strcmp(super->cl_ID, ROOTCLASS) != 0)
67 MUI_FreeClass(super);
69 else
71 /* Re-add the class to the list since freeing it failed */
72 ZUNE_AddBuiltinClass(cl, MUIMasterBase);
74 /* And also increase the reference counter again */
75 count++;
78 cl->cl_Dispatcher.h_Data = count;
80 ReleaseSemaphore(&MUIMB(MUIMasterBase)->ZuneSemaphore);
82 else
84 ReleaseSemaphore(&MUIMB(MUIMasterBase)->ZuneSemaphore);
86 CloseLibrary((struct Library *)cl->cl_Dispatcher.h_Data);
89 AROS_LIBFUNC_EXIT
91 } /* MUIA_FreeClass */