Exemple #1
0
/**
 * Clean up a locale, once its reference count reaches zero.  This function is
 * called by xlocale_release(), it should not be called directly.
 */
static void
destruct_locale(void *l)
{
	locale_t loc = l;

	for (int type=0 ; type<XLC_LAST ; type++) {
		if (loc->components[type]) {
			xlocale_release(loc->components[type]);
		}
	}
	if (loc->csym) {
		free(loc->csym);
	}
	free(l);
}
Exemple #2
0
void *
__collate_load(const char *encoding, __unused locale_t unused)
{
	if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
		return &__xlocale_C_collate;
	}
	struct xlocale_collate *table = calloc(sizeof(struct xlocale_collate), 1);
	table->header.header.destructor = destruct_collate;
	// FIXME: Make sure that _LDP_CACHE is never returned.  We should be doing
	// the caching outside of this section
	if (__collate_load_tables_l(encoding, table) != _LDP_LOADED) {
		xlocale_release(table);
		return NULL;
	}
	return table;
}
Exemple #3
0
static void
set_thread_locale(locale_t loc)
{

	_once(&once_control, init_key);
	
	if (NULL != loc) {
		xlocale_retain((struct xlocale_refcounted*)loc);
	}
	locale_t old = pthread_getspecific(locale_info_key);
	if ((NULL != old) && (loc != old)) {
		xlocale_release((struct xlocale_refcounted*)old);
	}
	if (fake_tls) {
		thread_local_locale = loc;
	} else {
		pthread_setspecific(locale_info_key, loc);
	}
#ifndef __NO_TLS
	__thread_locale = loc;
	__set_thread_rune_locale(loc);
#endif
}