frexpl: Update regarding AIX.
[gnulib.git] / lib / gl_xlist.c
1 /* Abstract sequential list data type, with out-of-memory checking.
2    Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2009.
4
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.
9
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.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 #include <config.h>
19
20 /* Specification.  */
21 #include "gl_xlist.h"
22
23 #if !HAVE_INLINE
24
25 gl_list_t
26 gl_list_create_empty (gl_list_implementation_t implementation,
27                       gl_listelement_equals_fn equals_fn,
28                       gl_listelement_hashcode_fn hashcode_fn,
29                       gl_listelement_dispose_fn dispose_fn,
30                       bool allow_duplicates)
31 {
32   gl_list_t result =
33     gl_list_nx_create_empty (implementation, equals_fn, hashcode_fn, dispose_fn,
34                              allow_duplicates);
35   if (result == NULL)
36     xalloc_die ();
37   return result;
38 }
39
40 gl_list_t
41 gl_list_create (gl_list_implementation_t implementation,
42                 gl_listelement_equals_fn equals_fn,
43                 gl_listelement_hashcode_fn hashcode_fn,
44                 gl_listelement_dispose_fn dispose_fn,
45                 bool allow_duplicates,
46                 size_t count, const void **contents)
47 {
48   gl_list_t result =
49     gl_list_nx_create (implementation, equals_fn, hashcode_fn, dispose_fn,
50                        allow_duplicates, count, contents);
51   if (result == NULL)
52     xalloc_die ();
53   return result;
54 }
55
56 void
57 gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
58 {
59   int result = gl_list_node_nx_set_value (list, node, elt);
60   if (result < 0)
61     xalloc_die ();
62 }
63
64 gl_list_node_t
65 gl_list_set_at (gl_list_t list, size_t position, const void *elt)
66 {
67   gl_list_node_t result = gl_list_nx_set_at (list, position, elt);
68   if (result == NULL)
69     xalloc_die ();
70   return result;
71 }
72
73 gl_list_node_t
74 gl_list_add_first (gl_list_t list, const void *elt)
75 {
76   gl_list_node_t result = gl_list_nx_add_first (list, elt);
77   if (result == NULL)
78     xalloc_die ();
79   return result;
80 }
81
82 gl_list_node_t
83 gl_list_add_last (gl_list_t list, const void *elt)
84 {
85   gl_list_node_t result = gl_list_nx_add_last (list, elt);
86   if (result == NULL)
87     xalloc_die ();
88   return result;
89 }
90
91 gl_list_node_t
92 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
93 {
94   gl_list_node_t result = gl_list_nx_add_before (list, node, elt);
95   if (result == NULL)
96     xalloc_die ();
97   return result;
98 }
99
100 gl_list_node_t
101 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
102 {
103   gl_list_node_t result = gl_list_nx_add_after (list, node, elt);
104   if (result == NULL)
105     xalloc_die ();
106   return result;
107 }
108
109 gl_list_node_t
110 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
111 {
112   gl_list_node_t result = gl_list_nx_add_at (list, position, elt);
113   if (result == NULL)
114     xalloc_die ();
115   return result;
116 }
117
118 gl_list_node_t
119 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar,
120                    const void *elt)
121 {
122   gl_list_node_t result = gl_sortedlist_nx_add (list, compar, elt);
123   if (result == NULL)
124     xalloc_die ();
125   return result;
126 }
127
128 #endif