havelib: Fix for Solaris 11 OpenIndiana and Solaris 11 OmniOS.
[gnulib.git] / lib / gl_xset.h
blob04bab74aa4ae8251ed497fdeb8058ca59fa06740
1 /* Abstract set data type, with out-of-memory checking.
2 Copyright (C) 2009-2020 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_XSET_H
19 #define _GL_XSET_H
21 #include "gl_set.h"
22 #include "xalloc.h"
24 #ifndef _GL_INLINE_HEADER_BEGIN
25 #error "Please include config.h first."
26 #endif
27 _GL_INLINE_HEADER_BEGIN
28 #ifndef GL_XSET_INLINE
29 # define GL_XSET_INLINE _GL_INLINE
30 #endif
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 /* These functions are thin wrappers around the corresponding functions with
38 _nx_ infix from gl_set.h. Upon out-of-memory, they invoke xalloc_die (),
39 instead of returning an error indicator. */
40 #if 0 /* These are defined inline below. */
41 extern gl_set_t gl_set_create_empty (gl_set_implementation_t implementation,
42 gl_setelement_equals_fn equals_fn,
43 gl_setelement_hashcode_fn hashcode_fn,
44 gl_setelement_dispose_fn dispose_fn);
45 extern bool gl_set_add (gl_set_t set, const void *elt);
46 #endif
48 GL_XSET_INLINE gl_set_t
49 gl_set_create_empty (gl_set_implementation_t implementation,
50 gl_setelement_equals_fn equals_fn,
51 gl_setelement_hashcode_fn hashcode_fn,
52 gl_setelement_dispose_fn dispose_fn)
54 gl_set_t result =
55 gl_set_nx_create_empty (implementation, equals_fn, hashcode_fn, dispose_fn);
56 if (result == NULL)
57 xalloc_die ();
58 return result;
61 GL_XSET_INLINE bool
62 gl_set_add (gl_set_t set, const void *elt)
64 int result = gl_set_nx_add (set, elt);
65 if (result < 0)
66 xalloc_die ();
67 return result;
70 #ifdef __cplusplus
72 #endif
74 _GL_INLINE_HEADER_END
76 #endif /* _GL_XSET_H */