- Tabs to spaces.
[AROS.git] / workbench / libs / locale / closelocale.c
blob5aa2ac7fe4bcf2f4e92716e493fb42328ec0bcbc
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CloseLocale() - Close a locale structure.
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <proto/exec.h>
10 #include "locale_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/locale.h>
17 AROS_LH1(void, CloseLocale,
19 /* SYNOPSIS */
20 AROS_LHA(struct Locale *, locale, A0),
22 /* LOCATION */
23 struct LocaleBase *, LocaleBase, 7, Locale)
25 /* FUNCTION
26 Finish accessing a Locale.
28 INPUTS
29 locale - An opened locale. Note that NULL is a valid
30 parameter here, and will simply be ignored.
32 RESULT
33 The locale is released back to the system.
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 OpenLocale()
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 /* Best make sure we actually have something freeable. */
51 if (locale
52 && (locale != (struct Locale *)IntLB(LocaleBase)->lb_DefaultLocale))
54 /* Make sure we don't have any race conditions */
55 ObtainSemaphore(&IntLB(LocaleBase)->lb_LocaleLock);
56 if (--IntL(locale)->il_Count == 0)
58 /* Free the locale structure if it's not the current locale */
59 if (locale !=
60 (struct Locale *)IntLB(LocaleBase)->lb_CurrentLocale)
62 /* Close old .language, if any */
63 if (IntLB(locale)->lb_CurrentLocale->il_CurrentLanguage)
64 CloseLibrary(IntLB(locale)->lb_CurrentLocale->
65 il_CurrentLanguage);
67 /* Close old dos.catalog */
68 CloseCatalog(IntLB(locale)->lb_CurrentLocale->
69 il_DosCatalog);
71 FreeMem(locale, sizeof(struct IntLocale));
74 ReleaseSemaphore(&IntLB(LocaleBase)->lb_LocaleLock);
77 AROS_LIBFUNC_EXIT