locale-util: introduce common helper locale_variables_free() for freeing locale variable arrays

This commit is contained in:
Lennart Poettering
2018-11-14 17:01:55 +01:00
parent 13df9c398d
commit e6755a3350
5 changed files with 32 additions and 41 deletions
+10
View File
@@ -389,6 +389,16 @@ const char *special_glyph(SpecialGlyph code) {
return draw_table[is_locale_utf8()][code];
}
void locale_variables_free(char*l[_VARIABLE_LC_MAX]) {
LocaleVariable i;
if (!l)
return;
for (i = 0; i < _VARIABLE_LC_MAX; i++)
l[i] = mfree(l[i]);
}
static const char * const locale_variable_table[_VARIABLE_LC_MAX] = {
[VARIABLE_LANG] = "LANG",
[VARIABLE_LANGUAGE] = "LANGUAGE",
+5
View File
@@ -66,3 +66,8 @@ static inline void freelocalep(locale_t *p) {
freelocale(*p);
}
void locale_variables_free(char* l[_VARIABLE_LC_MAX]);
static inline void locale_variables_freep(char*(*l)[_VARIABLE_LC_MAX]) {
locale_variables_free(*l);
}