floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
[gnulib.git] / lib / xstriconveh.c
blob69beb578d7f98273e8836e0e47ab7107aba44495
1 /* Charset conversion with out-of-memory checking.
2 Copyright (C) 2009-2018 Free Software Foundation, Inc.
3 Written by Bruno Haible.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #include <config.h>
20 /* Specification. */
21 #include "xstriconveh.h"
23 #include <errno.h>
25 #include "striconveh.h"
26 #include "xalloc.h"
29 #if HAVE_ICONV
31 int
32 xmem_cd_iconveh (const char *src, size_t srclen,
33 const iconveh_t *cd,
34 enum iconv_ilseq_handler handler,
35 size_t *offsets,
36 char **resultp, size_t *lengthp)
38 int retval =
39 mem_cd_iconveh (src, srclen, cd, handler, offsets, resultp, lengthp);
41 if (retval < 0 && errno == ENOMEM)
42 xalloc_die ();
43 return retval;
46 char *
47 xstr_cd_iconveh (const char *src,
48 const iconveh_t *cd,
49 enum iconv_ilseq_handler handler)
51 char *result = str_cd_iconveh (src, cd, handler);
53 if (result == NULL && errno == ENOMEM)
54 xalloc_die ();
55 return result;
58 #endif
60 int
61 xmem_iconveh (const char *src, size_t srclen,
62 const char *from_codeset, const char *to_codeset,
63 enum iconv_ilseq_handler handler,
64 size_t *offsets,
65 char **resultp, size_t *lengthp)
67 int retval =
68 mem_iconveh (src, srclen, from_codeset, to_codeset, handler, offsets,
69 resultp, lengthp);
71 if (retval < 0 && errno == ENOMEM)
72 xalloc_die ();
73 return retval;
76 char *
77 xstr_iconveh (const char *src,
78 const char *from_codeset, const char *to_codeset,
79 enum iconv_ilseq_handler handler)
81 char *result = str_iconveh (src, from_codeset, to_codeset, handler);
83 if (result == NULL && errno == ENOMEM)
84 xalloc_die ();
85 return result;