]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/wcsmbsload.h
libio: Fix gconv-related memory leak [BZ #24583]
[thirdparty/glibc.git] / wcsmbs / wcsmbsload.h
CommitLineData
04277e02 1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
4bca4c17
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
4bca4c17
UD
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
4bca4c17 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
4bca4c17 18
01beb5b9
UD
19#ifndef _WCSMBSLOAD_H
20#define _WCSMBSLOAD_H 1
21
4bca4c17
UD
22#include <locale.h>
23#include <wchar.h>
24#include <locale/localeinfo.h>
25
26
27/* Contains pointers to the used functions in the `gconv' modules. */
28struct gconv_fcts
29 {
d64b6ad0 30 struct __gconv_step *towc;
129d706d 31 size_t towc_nsteps;
d64b6ad0 32 struct __gconv_step *tomb;
129d706d 33 size_t tomb_nsteps;
4bca4c17
UD
34 };
35
36/* Set of currently active conversion functions. */
96310297 37extern const struct gconv_fcts __wcsmbs_gconv_fcts_c attribute_hidden;
4bca4c17
UD
38
39/* Load conversion functions for the currently selected locale. */
8bcdb7e0
L
40extern void __wcsmbs_load_conv (struct __locale_data *new_category)
41 attribute_hidden;
4bca4c17 42
d64b6ad0 43/* Clone the current `__wcsmbs_load_conv' value. */
8bcdb7e0
L
44extern void __wcsmbs_clone_conv (struct gconv_fcts *copy)
45 attribute_hidden;
d64b6ad0 46
4e2e9999 47/* Find the conversion functions for converting to and from NAME. */
8bcdb7e0
L
48extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
49 attribute_hidden;
4e2e9999 50
96310297 51/* Function used for the `private.cleanup' hook. */
d7ccc6c9 52extern void _nl_cleanup_ctype (struct __locale_data *) attribute_hidden;
01beb5b9 53
7e740ab2 54extern void __wcsmbs_close_conv (struct gconv_fcts *conv) attribute_hidden;
01beb5b9 55
96310297 56#include <iconv/gconv_int.h>
01beb5b9
UD
57
58
59/* Load the function implementation if necessary. */
60extern struct __gconv_step *__wcsmbs_getfct (const char *to, const char *from,
61 size_t *nstepsp)
62 attribute_hidden;
63
f095bb72 64extern const struct __locale_data _nl_C_LC_CTYPE attribute_hidden;
01beb5b9 65
4bca4c17
UD
66/* Check whether the LC_CTYPE locale changed since the last call.
67 Update the pointers appropriately. */
96310297 68static inline const struct gconv_fcts *
f095bb72 69get_gconv_fcts (struct __locale_data *data)
4bca4c17 70{
a1ffb40e 71 if (__glibc_unlikely (data->private.ctype == NULL))
96310297 72 {
a1ffb40e 73 if (__glibc_unlikely (data == &_nl_C_LC_CTYPE))
96310297
RM
74 return &__wcsmbs_gconv_fcts_c;
75 __wcsmbs_load_conv (data);
76 }
77 return data->private.ctype;
4bca4c17 78}
01beb5b9
UD
79
80#endif /* wcsmbsload.h */