exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / gl_xoset.h
blob454463d36a1f211594f71dc8fc91818bcf8fd670
1 /* Abstract ordered set data type, with out-of-memory checking.
2 Copyright (C) 2009-2024 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
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 #ifndef _GL_XOSET_H
19 #define _GL_XOSET_H
21 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
22 _GL_ATTRIBUTE_RETURNS_NONNULL. */
23 #if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25 #endif
27 #include "gl_oset.h"
28 #include "xalloc.h"
30 _GL_INLINE_HEADER_BEGIN
31 #ifndef GL_XOSET_INLINE
32 # define GL_XOSET_INLINE _GL_INLINE
33 #endif
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 /* These functions are thin wrappers around the corresponding functions with
41 _nx_ infix from gl_oset.h. Upon out-of-memory, they invoke xalloc_die (),
42 instead of returning an error indicator. */
43 #if 0 /* These are defined inline below. */
44 extern gl_oset_t gl_oset_create_empty (gl_oset_implementation_t implementation,
45 gl_setelement_compar_fn compar_fn,
46 gl_setelement_dispose_fn dispose_fn)
47 /*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
48 _GL_ATTRIBUTE_RETURNS_NONNULL;
49 extern bool gl_oset_add (gl_oset_t set, const void *elt);
50 #endif
52 GL_XOSET_INLINE
53 /*_GL_ATTRIBUTE_DEALLOC (gl_oset_free, 1)*/
54 _GL_ATTRIBUTE_RETURNS_NONNULL
55 gl_oset_t
56 gl_oset_create_empty (gl_oset_implementation_t implementation,
57 gl_setelement_compar_fn compar_fn,
58 gl_setelement_dispose_fn dispose_fn)
60 gl_oset_t result =
61 gl_oset_nx_create_empty (implementation, compar_fn, dispose_fn);
62 if (result == NULL)
63 xalloc_die ();
64 return result;
67 GL_XOSET_INLINE bool
68 gl_oset_add (gl_oset_t set, const void *elt)
70 int result = gl_oset_nx_add (set, elt);
71 if (result < 0)
72 xalloc_die ();
73 return result;
76 #ifdef __cplusplus
78 #endif
80 _GL_INLINE_HEADER_END
82 #endif /* _GL_XOSET_H */