2016-08-15 23:34:40 +08:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
<<freelocale>>---free resources allocated for a locale object
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
freelocale
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
_freelocale_r
|
|
|
|
|
2017-11-30 15:20:53 +08:00
|
|
|
SYNOPSIS
|
2016-08-15 23:34:40 +08:00
|
|
|
#include <locale.h>
|
|
|
|
locale_t freelocale(locale_t <[locobj]>);
|
|
|
|
|
|
|
|
locale_t _freelocale_r(void *<[reent]>, locale_t <[locobj]>);
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
The <<freelocale>> function shall cause the resources allocated for a
|
|
|
|
locale object returned by a call to the <<newlocale>> or <<duplocale>>
|
|
|
|
functions to be released.
|
|
|
|
|
|
|
|
The behavior is undefined if the <[locobj]> argument is the special locale
|
|
|
|
object LC_GLOBAL_LOCALE or is not a valid locale object handle.
|
|
|
|
|
|
|
|
Any use of a locale object that has been freed results in undefined
|
|
|
|
behavior.
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
None.
|
|
|
|
|
|
|
|
PORTABILITY
|
|
|
|
<<freelocale>> is POSIX-1.2008.
|
|
|
|
*/
|
|
|
|
|
2016-07-24 03:40:50 +08:00
|
|
|
#include <newlib.h>
|
|
|
|
#include <reent.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "setlocale.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
_freelocale_r (struct _reent *p, struct __locale_t *locobj)
|
|
|
|
{
|
2016-08-23 18:49:23 +08:00
|
|
|
/* Nothing to do on !_MB_CAPABLE targets. */
|
|
|
|
#ifdef _MB_CAPABLE
|
2016-07-24 03:40:50 +08:00
|
|
|
/* Sanity check. The "C" locale is static, don't try to free it. */
|
2016-08-23 18:49:23 +08:00
|
|
|
if (!locobj || locobj == __get_C_locale () || locobj == LC_GLOBAL_LOCALE)
|
2016-07-24 03:40:50 +08:00
|
|
|
return;
|
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
|
|
|
for (int i = 1; i < _LC_LAST; ++i)
|
|
|
|
if (locobj->lc_cat[i].buf)
|
|
|
|
{
|
|
|
|
_free_r (p, (void *) locobj->lc_cat[i].ptr);
|
|
|
|
_free_r (p, locobj->lc_cat[i].buf);
|
|
|
|
}
|
2016-08-23 18:43:40 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2016-07-24 03:40:50 +08:00
|
|
|
_free_r (p, locobj);
|
2016-08-23 18:49:23 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2016-07-24 03:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
freelocale (struct __locale_t *locobj)
|
|
|
|
{
|
|
|
|
_freelocale_r (_REENT, locobj);
|
|
|
|
}
|