1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include "ordered-set.h"
7 int _ordered_set_ensure_allocated(OrderedSet
**s
, const struct hash_ops
*ops HASHMAP_DEBUG_PARAMS
) {
11 *s
= _ordered_set_new(ops HASHMAP_DEBUG_PASS_ARGS
);
18 int _ordered_set_ensure_put(OrderedSet
**s
, const struct hash_ops
*ops
, void *p HASHMAP_DEBUG_PARAMS
) {
21 r
= _ordered_set_ensure_allocated(s
, ops HASHMAP_DEBUG_PASS_ARGS
);
25 return ordered_set_put(*s
, p
);
28 int ordered_set_consume(OrderedSet
*s
, void *p
) {
31 r
= ordered_set_put(s
, p
);
38 int ordered_set_put_strdup(OrderedSet
*s
, const char *p
) {
49 r
= ordered_set_consume(s
, c
);
56 int ordered_set_put_strdupv(OrderedSet
*s
, char **l
) {
61 r
= ordered_set_put_strdup(s
, *i
);
71 int ordered_set_put_string_set(OrderedSet
*s
, OrderedSet
*l
) {
75 /* Like ordered_set_put_strv, but for an OrderedSet of strings */
77 ORDERED_SET_FOREACH(p
, l
) {
78 r
= ordered_set_put_strdup(s
, p
);
88 void ordered_set_print(FILE *f
, const char *field
, OrderedSet
*s
) {
92 if (ordered_set_isempty(s
))
97 ORDERED_SET_FOREACH(p
, s
)
98 fputs_with_space(f
, p
, NULL
, &space
);