Coverage Report

Created: 2025-07-11 06:45

/src/croaring/include/roaring/containers/containers.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef CONTAINERS_CONTAINERS_H
2
#define CONTAINERS_CONTAINERS_H
3
4
#include <assert.h>
5
#include <stdbool.h>
6
#include <stdio.h>
7
8
#include <roaring/bitset_util.h>
9
#include <roaring/containers/array.h>
10
#include <roaring/containers/bitset.h>
11
#include <roaring/containers/convert.h>
12
#include <roaring/containers/mixed_andnot.h>
13
#include <roaring/containers/mixed_equal.h>
14
#include <roaring/containers/mixed_intersection.h>
15
#include <roaring/containers/mixed_negation.h>
16
#include <roaring/containers/mixed_subset.h>
17
#include <roaring/containers/mixed_union.h>
18
#include <roaring/containers/mixed_xor.h>
19
#include <roaring/containers/run.h>
20
21
#ifdef __cplusplus
22
extern "C" {
23
namespace roaring {
24
namespace internal {
25
#endif
26
27
// would enum be possible or better?
28
29
/**
30
 * The switch case statements follow
31
 * BITSET_CONTAINER_TYPE -- ARRAY_CONTAINER_TYPE -- RUN_CONTAINER_TYPE
32
 * so it makes more sense to number them 1, 2, 3 (in the vague hope that the
33
 * compiler might exploit this ordering).
34
 */
35
36
1.71M
#define BITSET_CONTAINER_TYPE 1
37
17.3M
#define ARRAY_CONTAINER_TYPE 2
38
3.10M
#define RUN_CONTAINER_TYPE 3
39
11.0M
#define SHARED_CONTAINER_TYPE 4
40
41
/**
42
 * Macros for pairing container type codes, suitable for switch statements.
43
 * Use PAIR_CONTAINER_TYPES() for the switch, CONTAINER_PAIR() for the cases:
44
 *
45
 *     switch (PAIR_CONTAINER_TYPES(type1, type2)) {
46
 *        case CONTAINER_PAIR(BITSET,ARRAY):
47
 *        ...
48
 *     }
49
 */
50
297k
#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
51
52
#define CONTAINER_PAIR(name1, name2) \
53
297k
    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
54
55
/**
56
 * A shared container is a wrapper around a container
57
 * with reference counting.
58
 */
59
STRUCT_CONTAINER(shared_container_s) {
60
    container_t *container;
61
    uint8_t typecode;
62
    croaring_refcount_t counter;  // to be managed atomically
63
};
64
65
typedef struct shared_container_s shared_container_t;
66
67
0
#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
68
0
#define const_CAST_shared(c) CAST(const shared_container_t *, c)
69
#define movable_CAST_shared(c) movable_CAST(shared_container_t **, c)
70
71
/*
72
 * With copy_on_write = true
73
 *  Create a new shared container if the typecode is not SHARED_CONTAINER_TYPE,
74
 * otherwise, increase the count
75
 * If copy_on_write = false, then clone.
76
 * Return NULL in case of failure.
77
 **/
78
container_t *get_copy_of_container(container_t *container, uint8_t *typecode,
79
                                   bool copy_on_write);
80
81
/* Frees a shared container (actually decrement its counter and only frees when
82
 * the counter falls to zero). */
83
void shared_container_free(shared_container_t *container);
84
85
/* extract a copy from the shared container, freeing the shared container if
86
there is just one instance left,
87
clone instances when the counter is higher than one
88
*/
89
container_t *shared_container_extract_copy(shared_container_t *container,
90
                                           uint8_t *typecode);
91
92
/* access to container underneath */
93
static inline const container_t *container_unwrap_shared(
94
2.49M
    const container_t *candidate_shared_container, uint8_t *type) {
95
2.49M
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
2.49M
    } else {
100
2.49M
        return candidate_shared_container;
101
2.49M
    }
102
2.49M
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_unwrap_shared(roaring::api::container_s const*, unsigned char*)
roaring.c:container_unwrap_shared
Line
Count
Source
94
1.50M
    const container_t *candidate_shared_container, uint8_t *type) {
95
1.50M
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
1.50M
    } else {
100
1.50M
        return candidate_shared_container;
101
1.50M
    }
102
1.50M
}
roaring_array.c:container_unwrap_shared
Line
Count
Source
94
418k
    const container_t *candidate_shared_container, uint8_t *type) {
95
418k
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
418k
    } else {
100
418k
        return candidate_shared_container;
101
418k
    }
102
418k
}
containers.c:container_unwrap_shared
Line
Count
Source
94
5.52k
    const container_t *candidate_shared_container, uint8_t *type) {
95
5.52k
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
5.52k
    } else {
100
5.52k
        return candidate_shared_container;
101
5.52k
    }
102
5.52k
}
Unexecuted instantiation: convert.c:container_unwrap_shared
Unexecuted instantiation: mixed_negation.c:container_unwrap_shared
Unexecuted instantiation: mixed_xor.c:container_unwrap_shared
Unexecuted instantiation: mixed_andnot.c:container_unwrap_shared
roaring64.c:container_unwrap_shared
Line
Count
Source
94
560k
    const container_t *candidate_shared_container, uint8_t *type) {
95
560k
    if (*type == SHARED_CONTAINER_TYPE) {
96
0
        *type = const_CAST_shared(candidate_shared_container)->typecode;
97
0
        assert(*type != SHARED_CONTAINER_TYPE);
98
0
        return const_CAST_shared(candidate_shared_container)->container;
99
560k
    } else {
100
560k
        return candidate_shared_container;
101
560k
    }
102
560k
}
103
104
/* access to container underneath */
105
static inline container_t *container_mutable_unwrap_shared(container_t *c,
106
5.36k
                                                           uint8_t *type) {
107
5.36k
    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
108
0
        *type = CAST_shared(c)->typecode;
109
0
        assert(*type != SHARED_CONTAINER_TYPE);
110
0
        return CAST_shared(c)->container;  // return the enclosed container
111
5.36k
    } else {
112
5.36k
        return c;  // wasn't shared, so return as-is
113
5.36k
    }
114
5.36k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_mutable_unwrap_shared(roaring::api::container_s*, unsigned char*)
roaring.c:container_mutable_unwrap_shared
Line
Count
Source
106
5.36k
                                                           uint8_t *type) {
107
5.36k
    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
108
0
        *type = CAST_shared(c)->typecode;
109
0
        assert(*type != SHARED_CONTAINER_TYPE);
110
0
        return CAST_shared(c)->container;  // return the enclosed container
111
5.36k
    } else {
112
5.36k
        return c;  // wasn't shared, so return as-is
113
5.36k
    }
114
5.36k
}
Unexecuted instantiation: roaring_array.c:container_mutable_unwrap_shared
Unexecuted instantiation: containers.c:container_mutable_unwrap_shared
Unexecuted instantiation: convert.c:container_mutable_unwrap_shared
Unexecuted instantiation: mixed_negation.c:container_mutable_unwrap_shared
Unexecuted instantiation: mixed_xor.c:container_mutable_unwrap_shared
Unexecuted instantiation: mixed_andnot.c:container_mutable_unwrap_shared
Unexecuted instantiation: roaring64.c:container_mutable_unwrap_shared
115
116
/* access to container underneath and queries its type */
117
261k
static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
118
261k
    if (type == SHARED_CONTAINER_TYPE) {
119
0
        return const_CAST_shared(c)->typecode;
120
261k
    } else {
121
261k
        return type;
122
261k
    }
123
261k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::get_container_type(roaring::api::container_s const*, unsigned char)
roaring.c:get_container_type
Line
Count
Source
117
85.2k
static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
118
85.2k
    if (type == SHARED_CONTAINER_TYPE) {
119
0
        return const_CAST_shared(c)->typecode;
120
85.2k
    } else {
121
85.2k
        return type;
122
85.2k
    }
123
85.2k
}
roaring_array.c:get_container_type
Line
Count
Source
117
175k
static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
118
175k
    if (type == SHARED_CONTAINER_TYPE) {
119
0
        return const_CAST_shared(c)->typecode;
120
175k
    } else {
121
175k
        return type;
122
175k
    }
123
175k
}
Unexecuted instantiation: containers.c:get_container_type
Unexecuted instantiation: convert.c:get_container_type
Unexecuted instantiation: mixed_negation.c:get_container_type
Unexecuted instantiation: mixed_xor.c:get_container_type
Unexecuted instantiation: mixed_andnot.c:get_container_type
Unexecuted instantiation: roaring64.c:get_container_type
124
125
/**
126
 * Copies a container, requires a typecode. This allocates new memory, caller
127
 * is responsible for deallocation. If the container is not shared, then it is
128
 * physically cloned. Sharable containers are not cloneable.
129
 */
130
container_t *container_clone(const container_t *container, uint8_t typecode);
131
132
/* access to container underneath, cloning it if needed */
133
static inline container_t *get_writable_copy_if_shared(container_t *c,
134
8.08M
                                                       uint8_t *type) {
135
8.08M
    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
136
0
        return shared_container_extract_copy(CAST_shared(c), type);
137
8.08M
    } else {
138
8.08M
        return c;  // not shared, so return as-is
139
8.08M
    }
140
8.08M
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::get_writable_copy_if_shared(roaring::api::container_s*, unsigned char*)
roaring.c:get_writable_copy_if_shared
Line
Count
Source
134
7.58M
                                                       uint8_t *type) {
135
7.58M
    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
136
0
        return shared_container_extract_copy(CAST_shared(c), type);
137
7.58M
    } else {
138
7.58M
        return c;  // not shared, so return as-is
139
7.58M
    }
140
7.58M
}
Unexecuted instantiation: roaring_array.c:get_writable_copy_if_shared
Unexecuted instantiation: containers.c:get_writable_copy_if_shared
Unexecuted instantiation: convert.c:get_writable_copy_if_shared
Unexecuted instantiation: mixed_negation.c:get_writable_copy_if_shared
Unexecuted instantiation: mixed_xor.c:get_writable_copy_if_shared
Unexecuted instantiation: mixed_andnot.c:get_writable_copy_if_shared
roaring64.c:get_writable_copy_if_shared
Line
Count
Source
134
497k
                                                       uint8_t *type) {
135
497k
    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
136
0
        return shared_container_extract_copy(CAST_shared(c), type);
137
497k
    } else {
138
497k
        return c;  // not shared, so return as-is
139
497k
    }
140
497k
}
141
142
/**
143
 * End of shared container code
144
 */
145
146
static const char *container_names[] = {"bitset", "array", "run", "shared"};
147
static const char *shared_container_names[] = {
148
    "bitset (shared)", "array (shared)", "run (shared)"};
149
150
// no matter what the initial container was, convert it to a bitset
151
// if a new container is produced, caller responsible for freeing the previous
152
// one
153
// container should not be a shared container
154
static inline bitset_container_t *container_to_bitset(container_t *c,
155
0
                                                      uint8_t typecode) {
156
0
    bitset_container_t *result = NULL;
157
0
    switch (typecode) {
158
0
        case BITSET_CONTAINER_TYPE:
159
0
            return CAST_bitset(c);  // nothing to do
160
0
        case ARRAY_CONTAINER_TYPE:
161
0
            result = bitset_container_from_array(CAST_array(c));
162
0
            return result;
163
0
        case RUN_CONTAINER_TYPE:
164
0
            result = bitset_container_from_run(CAST_run(c));
165
0
            return result;
166
0
        case SHARED_CONTAINER_TYPE:
167
0
            assert(false);
168
0
            roaring_unreachable;
169
0
    }
170
0
    assert(false);
171
0
    roaring_unreachable;
172
0
    return 0;  // unreached
173
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_to_bitset(roaring::api::container_s*, unsigned char)
Unexecuted instantiation: roaring.c:container_to_bitset
Unexecuted instantiation: roaring_array.c:container_to_bitset
Unexecuted instantiation: containers.c:container_to_bitset
Unexecuted instantiation: convert.c:container_to_bitset
Unexecuted instantiation: mixed_negation.c:container_to_bitset
Unexecuted instantiation: mixed_xor.c:container_to_bitset
Unexecuted instantiation: mixed_andnot.c:container_to_bitset
Unexecuted instantiation: roaring64.c:container_to_bitset
174
175
/**
176
 * Get the container name from the typecode
177
 * (unused at time of writing)
178
 */
179
/*static inline const char *get_container_name(uint8_t typecode) {
180
    switch (typecode) {
181
        case BITSET_CONTAINER_TYPE:
182
            return container_names[0];
183
        case ARRAY_CONTAINER_TYPE:
184
            return container_names[1];
185
        case RUN_CONTAINER_TYPE:
186
            return container_names[2];
187
        case SHARED_CONTAINER_TYPE:
188
            return container_names[3];
189
        default:
190
            assert(false);
191
            roaring_unreachable;
192
            return "unknown";
193
    }
194
}*/
195
196
static inline const char *get_full_container_name(const container_t *c,
197
0
                                                  uint8_t typecode) {
198
0
    switch (typecode) {
199
0
        case BITSET_CONTAINER_TYPE:
200
0
            return container_names[0];
201
0
        case ARRAY_CONTAINER_TYPE:
202
0
            return container_names[1];
203
0
        case RUN_CONTAINER_TYPE:
204
0
            return container_names[2];
205
0
        case SHARED_CONTAINER_TYPE:
206
0
            switch (const_CAST_shared(c)->typecode) {
207
0
                case BITSET_CONTAINER_TYPE:
208
0
                    return shared_container_names[0];
209
0
                case ARRAY_CONTAINER_TYPE:
210
0
                    return shared_container_names[1];
211
0
                case RUN_CONTAINER_TYPE:
212
0
                    return shared_container_names[2];
213
0
                default:
214
0
                    assert(false);
215
0
                    roaring_unreachable;
216
0
                    return "unknown";
217
0
            }
218
0
            break;
219
0
        default:
220
0
            assert(false);
221
0
            roaring_unreachable;
222
0
            return "unknown";
223
0
    }
224
0
    roaring_unreachable;
225
0
    return NULL;
226
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::get_full_container_name(roaring::api::container_s const*, unsigned char)
Unexecuted instantiation: roaring.c:get_full_container_name
Unexecuted instantiation: roaring_array.c:get_full_container_name
Unexecuted instantiation: containers.c:get_full_container_name
Unexecuted instantiation: convert.c:get_full_container_name
Unexecuted instantiation: mixed_negation.c:get_full_container_name
Unexecuted instantiation: mixed_xor.c:get_full_container_name
Unexecuted instantiation: mixed_andnot.c:get_full_container_name
Unexecuted instantiation: roaring64.c:get_full_container_name
227
228
/**
229
 * Get the container cardinality (number of elements), requires a  typecode
230
 */
231
static inline int container_get_cardinality(const container_t *c,
232
523k
                                            uint8_t typecode) {
233
523k
    c = container_unwrap_shared(c, &typecode);
234
523k
    switch (typecode) {
235
86.8k
        case BITSET_CONTAINER_TYPE:
236
86.8k
            return bitset_container_cardinality(const_CAST_bitset(c));
237
87.9k
        case ARRAY_CONTAINER_TYPE:
238
87.9k
            return array_container_cardinality(const_CAST_array(c));
239
349k
        case RUN_CONTAINER_TYPE:
240
349k
            return run_container_cardinality(const_CAST_run(c));
241
523k
    }
242
0
    assert(false);
243
0
    roaring_unreachable;
244
0
    return 0;  // unreached
245
523k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_get_cardinality(roaring::api::container_s const*, unsigned char)
roaring.c:container_get_cardinality
Line
Count
Source
232
406k
                                            uint8_t typecode) {
233
406k
    c = container_unwrap_shared(c, &typecode);
234
406k
    switch (typecode) {
235
7.67k
        case BITSET_CONTAINER_TYPE:
236
7.67k
            return bitset_container_cardinality(const_CAST_bitset(c));
237
55.3k
        case ARRAY_CONTAINER_TYPE:
238
55.3k
            return array_container_cardinality(const_CAST_array(c));
239
343k
        case RUN_CONTAINER_TYPE:
240
343k
            return run_container_cardinality(const_CAST_run(c));
241
406k
    }
242
0
    assert(false);
243
0
    roaring_unreachable;
244
0
    return 0;  // unreached
245
406k
}
roaring_array.c:container_get_cardinality
Line
Count
Source
232
85.2k
                                            uint8_t typecode) {
233
85.2k
    c = container_unwrap_shared(c, &typecode);
234
85.2k
    switch (typecode) {
235
79.1k
        case BITSET_CONTAINER_TYPE:
236
79.1k
            return bitset_container_cardinality(const_CAST_bitset(c));
237
6.15k
        case ARRAY_CONTAINER_TYPE:
238
6.15k
            return array_container_cardinality(const_CAST_array(c));
239
0
        case RUN_CONTAINER_TYPE:
240
0
            return run_container_cardinality(const_CAST_run(c));
241
85.2k
    }
242
0
    assert(false);
243
0
    roaring_unreachable;
244
0
    return 0;  // unreached
245
85.2k
}
Unexecuted instantiation: containers.c:container_get_cardinality
Unexecuted instantiation: convert.c:container_get_cardinality
Unexecuted instantiation: mixed_negation.c:container_get_cardinality
Unexecuted instantiation: mixed_xor.c:container_get_cardinality
Unexecuted instantiation: mixed_andnot.c:container_get_cardinality
roaring64.c:container_get_cardinality
Line
Count
Source
232
31.6k
                                            uint8_t typecode) {
233
31.6k
    c = container_unwrap_shared(c, &typecode);
234
31.6k
    switch (typecode) {
235
28
        case BITSET_CONTAINER_TYPE:
236
28
            return bitset_container_cardinality(const_CAST_bitset(c));
237
26.4k
        case ARRAY_CONTAINER_TYPE:
238
26.4k
            return array_container_cardinality(const_CAST_array(c));
239
5.17k
        case RUN_CONTAINER_TYPE:
240
5.17k
            return run_container_cardinality(const_CAST_run(c));
241
31.6k
    }
242
0
    assert(false);
243
0
    roaring_unreachable;
244
0
    return 0;  // unreached
245
31.6k
}
246
247
// returns true if a container is known to be full. Note that a lazy bitset
248
// container
249
// might be full without us knowing
250
6.05k
static inline bool container_is_full(const container_t *c, uint8_t typecode) {
251
6.05k
    c = container_unwrap_shared(c, &typecode);
252
6.05k
    switch (typecode) {
253
0
        case BITSET_CONTAINER_TYPE:
254
0
            return bitset_container_cardinality(const_CAST_bitset(c)) ==
255
0
                   (1 << 16);
256
3.29k
        case ARRAY_CONTAINER_TYPE:
257
3.29k
            return array_container_cardinality(const_CAST_array(c)) ==
258
3.29k
                   (1 << 16);
259
2.76k
        case RUN_CONTAINER_TYPE:
260
2.76k
            return run_container_is_full(const_CAST_run(c));
261
6.05k
    }
262
0
    assert(false);
263
0
    roaring_unreachable;
264
0
    return 0;  // unreached
265
6.05k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_is_full(roaring::api::container_s const*, unsigned char)
roaring.c:container_is_full
Line
Count
Source
250
6.05k
static inline bool container_is_full(const container_t *c, uint8_t typecode) {
251
6.05k
    c = container_unwrap_shared(c, &typecode);
252
6.05k
    switch (typecode) {
253
0
        case BITSET_CONTAINER_TYPE:
254
0
            return bitset_container_cardinality(const_CAST_bitset(c)) ==
255
0
                   (1 << 16);
256
3.29k
        case ARRAY_CONTAINER_TYPE:
257
3.29k
            return array_container_cardinality(const_CAST_array(c)) ==
258
3.29k
                   (1 << 16);
259
2.76k
        case RUN_CONTAINER_TYPE:
260
2.76k
            return run_container_is_full(const_CAST_run(c));
261
6.05k
    }
262
0
    assert(false);
263
0
    roaring_unreachable;
264
0
    return 0;  // unreached
265
6.05k
}
Unexecuted instantiation: roaring_array.c:container_is_full
Unexecuted instantiation: containers.c:container_is_full
Unexecuted instantiation: convert.c:container_is_full
Unexecuted instantiation: mixed_negation.c:container_is_full
Unexecuted instantiation: mixed_xor.c:container_is_full
Unexecuted instantiation: mixed_andnot.c:container_is_full
Unexecuted instantiation: roaring64.c:container_is_full
266
267
5.36k
static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
268
5.36k
    c = container_mutable_unwrap_shared(c, &type);
269
5.36k
    switch (type) {
270
0
        case BITSET_CONTAINER_TYPE:
271
0
            return 0;  // no shrinking possible
272
3.29k
        case ARRAY_CONTAINER_TYPE:
273
3.29k
            return array_container_shrink_to_fit(CAST_array(c));
274
2.07k
        case RUN_CONTAINER_TYPE:
275
2.07k
            return run_container_shrink_to_fit(CAST_run(c));
276
5.36k
    }
277
0
    assert(false);
278
0
    roaring_unreachable;
279
0
    return 0;  // unreached
280
5.36k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_shrink_to_fit(roaring::api::container_s*, unsigned char)
roaring.c:container_shrink_to_fit
Line
Count
Source
267
5.36k
static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
268
5.36k
    c = container_mutable_unwrap_shared(c, &type);
269
5.36k
    switch (type) {
270
0
        case BITSET_CONTAINER_TYPE:
271
0
            return 0;  // no shrinking possible
272
3.29k
        case ARRAY_CONTAINER_TYPE:
273
3.29k
            return array_container_shrink_to_fit(CAST_array(c));
274
2.07k
        case RUN_CONTAINER_TYPE:
275
2.07k
            return run_container_shrink_to_fit(CAST_run(c));
276
5.36k
    }
277
0
    assert(false);
278
0
    roaring_unreachable;
279
0
    return 0;  // unreached
280
5.36k
}
Unexecuted instantiation: roaring_array.c:container_shrink_to_fit
Unexecuted instantiation: containers.c:container_shrink_to_fit
Unexecuted instantiation: convert.c:container_shrink_to_fit
Unexecuted instantiation: mixed_negation.c:container_shrink_to_fit
Unexecuted instantiation: mixed_xor.c:container_shrink_to_fit
Unexecuted instantiation: mixed_andnot.c:container_shrink_to_fit
Unexecuted instantiation: roaring64.c:container_shrink_to_fit
281
282
/**
283
 * make a container with a run of ones
284
 */
285
/* initially always use a run container, even if an array might be
286
 * marginally
287
 * smaller */
288
static inline container_t *container_range_of_ones(uint32_t range_start,
289
                                                   uint32_t range_end,
290
97.8k
                                                   uint8_t *result_type) {
291
97.8k
    assert(range_end >= range_start);
292
97.8k
    uint64_t cardinality = range_end - range_start + 1;
293
97.8k
    if (cardinality <= 2) {
294
162
        *result_type = ARRAY_CONTAINER_TYPE;
295
162
        return array_container_create_range(range_start, range_end);
296
97.6k
    } else {
297
97.6k
        *result_type = RUN_CONTAINER_TYPE;
298
97.6k
        return run_container_create_range(range_start, range_end);
299
97.6k
    }
300
97.8k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_range_of_ones(unsigned int, unsigned int, unsigned char*)
roaring.c:container_range_of_ones
Line
Count
Source
290
97.8k
                                                   uint8_t *result_type) {
291
97.8k
    assert(range_end >= range_start);
292
97.8k
    uint64_t cardinality = range_end - range_start + 1;
293
97.8k
    if (cardinality <= 2) {
294
162
        *result_type = ARRAY_CONTAINER_TYPE;
295
162
        return array_container_create_range(range_start, range_end);
296
97.6k
    } else {
297
97.6k
        *result_type = RUN_CONTAINER_TYPE;
298
97.6k
        return run_container_create_range(range_start, range_end);
299
97.6k
    }
300
97.8k
}
Unexecuted instantiation: roaring_array.c:container_range_of_ones
Unexecuted instantiation: containers.c:container_range_of_ones
Unexecuted instantiation: convert.c:container_range_of_ones
Unexecuted instantiation: mixed_negation.c:container_range_of_ones
Unexecuted instantiation: mixed_xor.c:container_range_of_ones
Unexecuted instantiation: mixed_andnot.c:container_range_of_ones
Unexecuted instantiation: roaring64.c:container_range_of_ones
301
302
/*  Create a container with all the values between in [min,max) at a
303
    distance k*step from min. */
304
static inline container_t *container_from_range(uint8_t *type, uint32_t min,
305
77.3k
                                                uint32_t max, uint16_t step) {
306
77.3k
    if (step == 0) return NULL;  // being paranoid
307
77.3k
    if (step == 1) {
308
77.3k
        return container_range_of_ones(min, max, type);
309
        // Note: the result is not always a run (need to check the cardinality)
310
        //*type = RUN_CONTAINER_TYPE;
311
        // return run_container_create_range(min, max);
312
77.3k
    }
313
0
    int size = (max - min + step - 1) / step;
314
0
    if (size <= DEFAULT_MAX_SIZE) {  // array container
315
0
        *type = ARRAY_CONTAINER_TYPE;
316
0
        array_container_t *array = array_container_create_given_capacity(size);
317
0
        array_container_add_from_range(array, min, max, step);
318
0
        assert(array->cardinality == size);
319
0
        return array;
320
0
    } else {  // bitset container
321
0
        *type = BITSET_CONTAINER_TYPE;
322
0
        bitset_container_t *bitset = bitset_container_create();
323
0
        bitset_container_add_from_range(bitset, min, max, step);
324
0
        assert(bitset->cardinality == size);
325
0
        return bitset;
326
0
    }
327
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_from_range(unsigned char*, unsigned int, unsigned int, unsigned short)
roaring.c:container_from_range
Line
Count
Source
305
77.3k
                                                uint32_t max, uint16_t step) {
306
77.3k
    if (step == 0) return NULL;  // being paranoid
307
77.3k
    if (step == 1) {
308
77.3k
        return container_range_of_ones(min, max, type);
309
        // Note: the result is not always a run (need to check the cardinality)
310
        //*type = RUN_CONTAINER_TYPE;
311
        // return run_container_create_range(min, max);
312
77.3k
    }
313
0
    int size = (max - min + step - 1) / step;
314
0
    if (size <= DEFAULT_MAX_SIZE) {  // array container
315
0
        *type = ARRAY_CONTAINER_TYPE;
316
0
        array_container_t *array = array_container_create_given_capacity(size);
317
0
        array_container_add_from_range(array, min, max, step);
318
0
        assert(array->cardinality == size);
319
0
        return array;
320
0
    } else {  // bitset container
321
0
        *type = BITSET_CONTAINER_TYPE;
322
0
        bitset_container_t *bitset = bitset_container_create();
323
0
        bitset_container_add_from_range(bitset, min, max, step);
324
0
        assert(bitset->cardinality == size);
325
0
        return bitset;
326
0
    }
327
0
}
Unexecuted instantiation: roaring_array.c:container_from_range
Unexecuted instantiation: containers.c:container_from_range
Unexecuted instantiation: convert.c:container_from_range
Unexecuted instantiation: mixed_negation.c:container_from_range
Unexecuted instantiation: mixed_xor.c:container_from_range
Unexecuted instantiation: mixed_andnot.c:container_from_range
Unexecuted instantiation: roaring64.c:container_from_range
328
329
/**
330
 * "repair" the container after lazy operations.
331
 */
332
static inline container_t *container_repair_after_lazy(container_t *c,
333
0
                                                       uint8_t *type) {
334
0
    c = get_writable_copy_if_shared(c, type);  // !!! unnecessary cloning
335
0
    container_t *result = NULL;
336
0
    switch (*type) {
337
0
        case BITSET_CONTAINER_TYPE: {
338
0
            bitset_container_t *bc = CAST_bitset(c);
339
0
            bc->cardinality = bitset_container_compute_cardinality(bc);
340
0
            if (bc->cardinality <= DEFAULT_MAX_SIZE) {
341
0
                result = array_container_from_bitset(bc);
342
0
                bitset_container_free(bc);
343
0
                *type = ARRAY_CONTAINER_TYPE;
344
0
                return result;
345
0
            }
346
0
            return c;
347
0
        }
348
0
        case ARRAY_CONTAINER_TYPE:
349
0
            return c;  // nothing to do
350
0
        case RUN_CONTAINER_TYPE:
351
0
            return convert_run_to_efficient_container_and_free(CAST_run(c),
352
0
                                                               type);
353
0
        case SHARED_CONTAINER_TYPE:
354
0
            assert(false);
355
0
    }
356
0
    assert(false);
357
0
    roaring_unreachable;
358
0
    return 0;  // unreached
359
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_repair_after_lazy(roaring::api::container_s*, unsigned char*)
Unexecuted instantiation: roaring.c:container_repair_after_lazy
Unexecuted instantiation: roaring_array.c:container_repair_after_lazy
Unexecuted instantiation: containers.c:container_repair_after_lazy
Unexecuted instantiation: convert.c:container_repair_after_lazy
Unexecuted instantiation: mixed_negation.c:container_repair_after_lazy
Unexecuted instantiation: mixed_xor.c:container_repair_after_lazy
Unexecuted instantiation: mixed_andnot.c:container_repair_after_lazy
Unexecuted instantiation: roaring64.c:container_repair_after_lazy
360
361
/**
362
 * Writes the underlying array to buf, outputs how many bytes were written.
363
 * This is meant to be byte-by-byte compatible with the Java and Go versions of
364
 * Roaring.
365
 * The number of bytes written should be
366
 * container_write(container, buf).
367
 *
368
 */
369
static inline int32_t container_write(const container_t *c, uint8_t typecode,
370
85.2k
                                      char *buf) {
371
85.2k
    c = container_unwrap_shared(c, &typecode);
372
85.2k
    switch (typecode) {
373
79.1k
        case BITSET_CONTAINER_TYPE:
374
79.1k
            return bitset_container_write(const_CAST_bitset(c), buf);
375
6.15k
        case ARRAY_CONTAINER_TYPE:
376
6.15k
            return array_container_write(const_CAST_array(c), buf);
377
0
        case RUN_CONTAINER_TYPE:
378
0
            return run_container_write(const_CAST_run(c), buf);
379
85.2k
    }
380
0
    assert(false);
381
0
    roaring_unreachable;
382
0
    return 0;  // unreached
383
85.2k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_write(roaring::api::container_s const*, unsigned char, char*)
Unexecuted instantiation: roaring.c:container_write
roaring_array.c:container_write
Line
Count
Source
370
85.2k
                                      char *buf) {
371
85.2k
    c = container_unwrap_shared(c, &typecode);
372
85.2k
    switch (typecode) {
373
79.1k
        case BITSET_CONTAINER_TYPE:
374
79.1k
            return bitset_container_write(const_CAST_bitset(c), buf);
375
6.15k
        case ARRAY_CONTAINER_TYPE:
376
6.15k
            return array_container_write(const_CAST_array(c), buf);
377
0
        case RUN_CONTAINER_TYPE:
378
0
            return run_container_write(const_CAST_run(c), buf);
379
85.2k
    }
380
0
    assert(false);
381
0
    roaring_unreachable;
382
0
    return 0;  // unreached
383
85.2k
}
Unexecuted instantiation: containers.c:container_write
Unexecuted instantiation: convert.c:container_write
Unexecuted instantiation: mixed_negation.c:container_write
Unexecuted instantiation: mixed_xor.c:container_write
Unexecuted instantiation: mixed_andnot.c:container_write
Unexecuted instantiation: roaring64.c:container_write
384
385
/**
386
 * Get the container size in bytes under portable serialization (see
387
 * container_write), requires a
388
 * typecode
389
 */
390
static inline int32_t container_size_in_bytes(const container_t *c,
391
175k
                                              uint8_t typecode) {
392
175k
    c = container_unwrap_shared(c, &typecode);
393
175k
    switch (typecode) {
394
158k
        case BITSET_CONTAINER_TYPE:
395
158k
            return bitset_container_size_in_bytes(const_CAST_bitset(c));
396
15.6k
        case ARRAY_CONTAINER_TYPE:
397
15.6k
            return array_container_size_in_bytes(const_CAST_array(c));
398
2.07k
        case RUN_CONTAINER_TYPE:
399
2.07k
            return run_container_size_in_bytes(const_CAST_run(c));
400
175k
    }
401
0
    assert(false);
402
0
    roaring_unreachable;
403
0
    return 0;  // unreached
404
175k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_size_in_bytes(roaring::api::container_s const*, unsigned char)
Unexecuted instantiation: roaring.c:container_size_in_bytes
roaring_array.c:container_size_in_bytes
Line
Count
Source
391
175k
                                              uint8_t typecode) {
392
175k
    c = container_unwrap_shared(c, &typecode);
393
175k
    switch (typecode) {
394
158k
        case BITSET_CONTAINER_TYPE:
395
158k
            return bitset_container_size_in_bytes(const_CAST_bitset(c));
396
15.6k
        case ARRAY_CONTAINER_TYPE:
397
15.6k
            return array_container_size_in_bytes(const_CAST_array(c));
398
2.07k
        case RUN_CONTAINER_TYPE:
399
2.07k
            return run_container_size_in_bytes(const_CAST_run(c));
400
175k
    }
401
0
    assert(false);
402
0
    roaring_unreachable;
403
0
    return 0;  // unreached
404
175k
}
Unexecuted instantiation: containers.c:container_size_in_bytes
Unexecuted instantiation: convert.c:container_size_in_bytes
Unexecuted instantiation: mixed_negation.c:container_size_in_bytes
Unexecuted instantiation: mixed_xor.c:container_size_in_bytes
Unexecuted instantiation: mixed_andnot.c:container_size_in_bytes
Unexecuted instantiation: roaring64.c:container_size_in_bytes
405
406
/**
407
 * print the container (useful for debugging), requires a  typecode
408
 */
409
void container_printf(const container_t *container, uint8_t typecode);
410
411
/**
412
 * print the content of the container as a comma-separated list of 32-bit values
413
 * starting at base, requires a  typecode
414
 */
415
void container_printf_as_uint32_array(const container_t *container,
416
                                      uint8_t typecode, uint32_t base);
417
418
bool container_internal_validate(const container_t *container, uint8_t typecode,
419
                                 const char **reason);
420
421
/**
422
 * Checks whether a container is not empty, requires a  typecode
423
 */
424
static inline bool container_nonzero_cardinality(const container_t *c,
425
181k
                                                 uint8_t typecode) {
426
181k
    c = container_unwrap_shared(c, &typecode);
427
181k
    switch (typecode) {
428
5.44k
        case BITSET_CONTAINER_TYPE:
429
5.44k
            return bitset_container_const_nonzero_cardinality(
430
5.44k
                const_CAST_bitset(c));
431
105k
        case ARRAY_CONTAINER_TYPE:
432
105k
            return array_container_nonzero_cardinality(const_CAST_array(c));
433
70.3k
        case RUN_CONTAINER_TYPE:
434
70.3k
            return run_container_nonzero_cardinality(const_CAST_run(c));
435
181k
    }
436
0
    assert(false);
437
0
    roaring_unreachable;
438
0
    return 0;  // unreached
439
181k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_nonzero_cardinality(roaring::api::container_s const*, unsigned char)
roaring.c:container_nonzero_cardinality
Line
Count
Source
425
181k
                                                 uint8_t typecode) {
426
181k
    c = container_unwrap_shared(c, &typecode);
427
181k
    switch (typecode) {
428
5.44k
        case BITSET_CONTAINER_TYPE:
429
5.44k
            return bitset_container_const_nonzero_cardinality(
430
5.44k
                const_CAST_bitset(c));
431
105k
        case ARRAY_CONTAINER_TYPE:
432
105k
            return array_container_nonzero_cardinality(const_CAST_array(c));
433
70.3k
        case RUN_CONTAINER_TYPE:
434
70.3k
            return run_container_nonzero_cardinality(const_CAST_run(c));
435
181k
    }
436
0
    assert(false);
437
0
    roaring_unreachable;
438
0
    return 0;  // unreached
439
181k
}
Unexecuted instantiation: roaring_array.c:container_nonzero_cardinality
Unexecuted instantiation: containers.c:container_nonzero_cardinality
Unexecuted instantiation: convert.c:container_nonzero_cardinality
Unexecuted instantiation: mixed_negation.c:container_nonzero_cardinality
Unexecuted instantiation: mixed_xor.c:container_nonzero_cardinality
Unexecuted instantiation: mixed_andnot.c:container_nonzero_cardinality
Unexecuted instantiation: roaring64.c:container_nonzero_cardinality
440
441
/**
442
 * Recover memory from a container, requires a  typecode
443
 */
444
void container_free(container_t *container, uint8_t typecode);
445
446
/**
447
 * Convert a container to an array of values, requires a  typecode as well as a
448
 * "base" (most significant values)
449
 * Returns number of ints added.
450
 */
451
static inline int container_to_uint32_array(uint32_t *output,
452
                                            const container_t *c,
453
71.9k
                                            uint8_t typecode, uint32_t base) {
454
71.9k
    c = container_unwrap_shared(c, &typecode);
455
71.9k
    switch (typecode) {
456
1.21k
        case BITSET_CONTAINER_TYPE:
457
1.21k
            return bitset_container_to_uint32_array(output,
458
1.21k
                                                    const_CAST_bitset(c), base);
459
5.02k
        case ARRAY_CONTAINER_TYPE:
460
5.02k
            return array_container_to_uint32_array(output, const_CAST_array(c),
461
5.02k
                                                   base);
462
65.7k
        case RUN_CONTAINER_TYPE:
463
65.7k
            return run_container_to_uint32_array(output, const_CAST_run(c),
464
65.7k
                                                 base);
465
71.9k
    }
466
0
    assert(false);
467
0
    roaring_unreachable;
468
0
    return 0;  // unreached
469
71.9k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_to_uint32_array(unsigned int*, roaring::api::container_s const*, unsigned char, unsigned int)
Unexecuted instantiation: roaring.c:container_to_uint32_array
roaring_array.c:container_to_uint32_array
Line
Count
Source
453
71.9k
                                            uint8_t typecode, uint32_t base) {
454
71.9k
    c = container_unwrap_shared(c, &typecode);
455
71.9k
    switch (typecode) {
456
1.21k
        case BITSET_CONTAINER_TYPE:
457
1.21k
            return bitset_container_to_uint32_array(output,
458
1.21k
                                                    const_CAST_bitset(c), base);
459
5.02k
        case ARRAY_CONTAINER_TYPE:
460
5.02k
            return array_container_to_uint32_array(output, const_CAST_array(c),
461
5.02k
                                                   base);
462
65.7k
        case RUN_CONTAINER_TYPE:
463
65.7k
            return run_container_to_uint32_array(output, const_CAST_run(c),
464
65.7k
                                                 base);
465
71.9k
    }
466
0
    assert(false);
467
0
    roaring_unreachable;
468
0
    return 0;  // unreached
469
71.9k
}
Unexecuted instantiation: containers.c:container_to_uint32_array
Unexecuted instantiation: convert.c:container_to_uint32_array
Unexecuted instantiation: mixed_negation.c:container_to_uint32_array
Unexecuted instantiation: mixed_xor.c:container_to_uint32_array
Unexecuted instantiation: mixed_andnot.c:container_to_uint32_array
Unexecuted instantiation: roaring64.c:container_to_uint32_array
470
471
/**
472
 * Add a value to a container, requires a  typecode, fills in new_typecode and
473
 * return (possibly different) container.
474
 * This function may allocate a new container, and caller is responsible for
475
 * memory deallocation
476
 */
477
static inline container_t *container_add(
478
    container_t *c, uint16_t val,
479
    uint8_t typecode,  // !!! should be second argument?
480
7.54M
    uint8_t *new_typecode) {
481
7.54M
    c = get_writable_copy_if_shared(c, &typecode);
482
7.54M
    switch (typecode) {
483
264k
        case BITSET_CONTAINER_TYPE:
484
264k
            bitset_container_set(CAST_bitset(c), val);
485
264k
            *new_typecode = BITSET_CONTAINER_TYPE;
486
264k
            return c;
487
6.78M
        case ARRAY_CONTAINER_TYPE: {
488
6.78M
            array_container_t *ac = CAST_array(c);
489
6.78M
            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
490
6.78M
                *new_typecode = ARRAY_CONTAINER_TYPE;
491
6.78M
                return ac;
492
6.78M
            } else {
493
91
                bitset_container_t *bitset = bitset_container_from_array(ac);
494
91
                bitset_container_add(bitset, val);
495
91
                *new_typecode = BITSET_CONTAINER_TYPE;
496
91
                return bitset;
497
91
            }
498
6.78M
        } break;
499
495k
        case RUN_CONTAINER_TYPE:
500
            // per Java, no container type adjustments are done (revisit?)
501
495k
            run_container_add(CAST_run(c), val);
502
495k
            *new_typecode = RUN_CONTAINER_TYPE;
503
495k
            return c;
504
0
        default:
505
0
            assert(false);
506
0
            roaring_unreachable;
507
0
            return NULL;
508
7.54M
    }
509
7.54M
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_add(roaring::api::container_s*, unsigned short, unsigned char, unsigned char*)
roaring.c:container_add
Line
Count
Source
480
7.04M
    uint8_t *new_typecode) {
481
7.04M
    c = get_writable_copy_if_shared(c, &typecode);
482
7.04M
    switch (typecode) {
483
259k
        case BITSET_CONTAINER_TYPE:
484
259k
            bitset_container_set(CAST_bitset(c), val);
485
259k
            *new_typecode = BITSET_CONTAINER_TYPE;
486
259k
            return c;
487
6.34M
        case ARRAY_CONTAINER_TYPE: {
488
6.34M
            array_container_t *ac = CAST_array(c);
489
6.34M
            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
490
6.34M
                *new_typecode = ARRAY_CONTAINER_TYPE;
491
6.34M
                return ac;
492
6.34M
            } else {
493
91
                bitset_container_t *bitset = bitset_container_from_array(ac);
494
91
                bitset_container_add(bitset, val);
495
91
                *new_typecode = BITSET_CONTAINER_TYPE;
496
91
                return bitset;
497
91
            }
498
6.34M
        } break;
499
441k
        case RUN_CONTAINER_TYPE:
500
            // per Java, no container type adjustments are done (revisit?)
501
441k
            run_container_add(CAST_run(c), val);
502
441k
            *new_typecode = RUN_CONTAINER_TYPE;
503
441k
            return c;
504
0
        default:
505
0
            assert(false);
506
0
            roaring_unreachable;
507
0
            return NULL;
508
7.04M
    }
509
7.04M
}
Unexecuted instantiation: roaring_array.c:container_add
Unexecuted instantiation: containers.c:container_add
Unexecuted instantiation: convert.c:container_add
Unexecuted instantiation: mixed_negation.c:container_add
Unexecuted instantiation: mixed_xor.c:container_add
Unexecuted instantiation: mixed_andnot.c:container_add
roaring64.c:container_add
Line
Count
Source
480
497k
    uint8_t *new_typecode) {
481
497k
    c = get_writable_copy_if_shared(c, &typecode);
482
497k
    switch (typecode) {
483
4.79k
        case BITSET_CONTAINER_TYPE:
484
4.79k
            bitset_container_set(CAST_bitset(c), val);
485
4.79k
            *new_typecode = BITSET_CONTAINER_TYPE;
486
4.79k
            return c;
487
439k
        case ARRAY_CONTAINER_TYPE: {
488
439k
            array_container_t *ac = CAST_array(c);
489
439k
            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
490
439k
                *new_typecode = ARRAY_CONTAINER_TYPE;
491
439k
                return ac;
492
439k
            } else {
493
0
                bitset_container_t *bitset = bitset_container_from_array(ac);
494
0
                bitset_container_add(bitset, val);
495
0
                *new_typecode = BITSET_CONTAINER_TYPE;
496
0
                return bitset;
497
0
            }
498
439k
        } break;
499
53.2k
        case RUN_CONTAINER_TYPE:
500
            // per Java, no container type adjustments are done (revisit?)
501
53.2k
            run_container_add(CAST_run(c), val);
502
53.2k
            *new_typecode = RUN_CONTAINER_TYPE;
503
53.2k
            return c;
504
0
        default:
505
0
            assert(false);
506
0
            roaring_unreachable;
507
0
            return NULL;
508
497k
    }
509
497k
}
510
511
/**
512
 * Remove a value from a container, requires a  typecode, fills in new_typecode
513
 * and
514
 * return (possibly different) container.
515
 * This function may allocate a new container, and caller is responsible for
516
 * memory deallocation
517
 */
518
static inline container_t *container_remove(
519
    container_t *c, uint16_t val,
520
    uint8_t typecode,  // !!! should be second argument?
521
9.34k
    uint8_t *new_typecode) {
522
9.34k
    c = get_writable_copy_if_shared(c, &typecode);
523
9.34k
    switch (typecode) {
524
1.58k
        case BITSET_CONTAINER_TYPE:
525
1.58k
            if (bitset_container_remove(CAST_bitset(c), val)) {
526
989
                int card = bitset_container_cardinality(CAST_bitset(c));
527
989
                if (card <= DEFAULT_MAX_SIZE) {
528
17
                    *new_typecode = ARRAY_CONTAINER_TYPE;
529
17
                    return array_container_from_bitset(CAST_bitset(c));
530
17
                }
531
989
            }
532
1.56k
            *new_typecode = typecode;
533
1.56k
            return c;
534
5.04k
        case ARRAY_CONTAINER_TYPE:
535
5.04k
            *new_typecode = typecode;
536
5.04k
            array_container_remove(CAST_array(c), val);
537
5.04k
            return c;
538
2.71k
        case RUN_CONTAINER_TYPE:
539
            // per Java, no container type adjustments are done (revisit?)
540
2.71k
            run_container_remove(CAST_run(c), val);
541
2.71k
            *new_typecode = RUN_CONTAINER_TYPE;
542
2.71k
            return c;
543
0
        default:
544
0
            assert(false);
545
0
            roaring_unreachable;
546
0
            return NULL;
547
9.34k
    }
548
9.34k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_remove(roaring::api::container_s*, unsigned short, unsigned char, unsigned char*)
roaring.c:container_remove
Line
Count
Source
521
9.34k
    uint8_t *new_typecode) {
522
9.34k
    c = get_writable_copy_if_shared(c, &typecode);
523
9.34k
    switch (typecode) {
524
1.58k
        case BITSET_CONTAINER_TYPE:
525
1.58k
            if (bitset_container_remove(CAST_bitset(c), val)) {
526
989
                int card = bitset_container_cardinality(CAST_bitset(c));
527
989
                if (card <= DEFAULT_MAX_SIZE) {
528
17
                    *new_typecode = ARRAY_CONTAINER_TYPE;
529
17
                    return array_container_from_bitset(CAST_bitset(c));
530
17
                }
531
989
            }
532
1.56k
            *new_typecode = typecode;
533
1.56k
            return c;
534
5.04k
        case ARRAY_CONTAINER_TYPE:
535
5.04k
            *new_typecode = typecode;
536
5.04k
            array_container_remove(CAST_array(c), val);
537
5.04k
            return c;
538
2.71k
        case RUN_CONTAINER_TYPE:
539
            // per Java, no container type adjustments are done (revisit?)
540
2.71k
            run_container_remove(CAST_run(c), val);
541
2.71k
            *new_typecode = RUN_CONTAINER_TYPE;
542
2.71k
            return c;
543
0
        default:
544
0
            assert(false);
545
0
            roaring_unreachable;
546
0
            return NULL;
547
9.34k
    }
548
9.34k
}
Unexecuted instantiation: roaring_array.c:container_remove
Unexecuted instantiation: containers.c:container_remove
Unexecuted instantiation: convert.c:container_remove
Unexecuted instantiation: mixed_negation.c:container_remove
Unexecuted instantiation: mixed_xor.c:container_remove
Unexecuted instantiation: mixed_andnot.c:container_remove
Unexecuted instantiation: roaring64.c:container_remove
549
550
/**
551
 * Check whether a value is in a container, requires a  typecode
552
 */
553
static inline bool container_contains(
554
    const container_t *c, uint16_t val,
555
    uint8_t typecode  // !!! should be second argument?
556
886k
) {
557
886k
    c = container_unwrap_shared(c, &typecode);
558
886k
    switch (typecode) {
559
20.6k
        case BITSET_CONTAINER_TYPE:
560
20.6k
            return bitset_container_get(const_CAST_bitset(c), val);
561
652k
        case ARRAY_CONTAINER_TYPE:
562
652k
            return array_container_contains(const_CAST_array(c), val);
563
212k
        case RUN_CONTAINER_TYPE:
564
212k
            return run_container_contains(const_CAST_run(c), val);
565
0
        default:
566
0
            assert(false);
567
0
            roaring_unreachable;
568
0
            return false;
569
886k
    }
570
886k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_contains(roaring::api::container_s const*, unsigned short, unsigned char)
roaring.c:container_contains
Line
Count
Source
556
357k
) {
557
357k
    c = container_unwrap_shared(c, &typecode);
558
357k
    switch (typecode) {
559
12.5k
        case BITSET_CONTAINER_TYPE:
560
12.5k
            return bitset_container_get(const_CAST_bitset(c), val);
561
213k
        case ARRAY_CONTAINER_TYPE:
562
213k
            return array_container_contains(const_CAST_array(c), val);
563
131k
        case RUN_CONTAINER_TYPE:
564
131k
            return run_container_contains(const_CAST_run(c), val);
565
0
        default:
566
0
            assert(false);
567
0
            roaring_unreachable;
568
0
            return false;
569
357k
    }
570
357k
}
Unexecuted instantiation: roaring_array.c:container_contains
Unexecuted instantiation: containers.c:container_contains
Unexecuted instantiation: convert.c:container_contains
Unexecuted instantiation: mixed_negation.c:container_contains
Unexecuted instantiation: mixed_xor.c:container_contains
Unexecuted instantiation: mixed_andnot.c:container_contains
roaring64.c:container_contains
Line
Count
Source
556
528k
) {
557
528k
    c = container_unwrap_shared(c, &typecode);
558
528k
    switch (typecode) {
559
8.10k
        case BITSET_CONTAINER_TYPE:
560
8.10k
            return bitset_container_get(const_CAST_bitset(c), val);
561
439k
        case ARRAY_CONTAINER_TYPE:
562
439k
            return array_container_contains(const_CAST_array(c), val);
563
81.0k
        case RUN_CONTAINER_TYPE:
564
81.0k
            return run_container_contains(const_CAST_run(c), val);
565
0
        default:
566
0
            assert(false);
567
0
            roaring_unreachable;
568
0
            return false;
569
528k
    }
570
528k
}
571
572
/**
573
 * Check whether a range of values from range_start (included) to range_end
574
 * (excluded) is in a container, requires a typecode
575
 */
576
static inline bool container_contains_range(
577
    const container_t *c, uint32_t range_start, uint32_t range_end,
578
    uint8_t typecode  // !!! should be second argument?
579
516
) {
580
516
    c = container_unwrap_shared(c, &typecode);
581
516
    switch (typecode) {
582
218
        case BITSET_CONTAINER_TYPE:
583
218
            return bitset_container_get_range(const_CAST_bitset(c), range_start,
584
218
                                              range_end);
585
104
        case ARRAY_CONTAINER_TYPE:
586
104
            return array_container_contains_range(const_CAST_array(c),
587
104
                                                  range_start, range_end);
588
194
        case RUN_CONTAINER_TYPE:
589
194
            return run_container_contains_range(const_CAST_run(c), range_start,
590
194
                                                range_end);
591
0
        default:
592
0
            assert(false);
593
0
            roaring_unreachable;
594
0
            return false;
595
516
    }
596
516
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_contains_range(roaring::api::container_s const*, unsigned int, unsigned int, unsigned char)
roaring.c:container_contains_range
Line
Count
Source
579
516
) {
580
516
    c = container_unwrap_shared(c, &typecode);
581
516
    switch (typecode) {
582
218
        case BITSET_CONTAINER_TYPE:
583
218
            return bitset_container_get_range(const_CAST_bitset(c), range_start,
584
218
                                              range_end);
585
104
        case ARRAY_CONTAINER_TYPE:
586
104
            return array_container_contains_range(const_CAST_array(c),
587
104
                                                  range_start, range_end);
588
194
        case RUN_CONTAINER_TYPE:
589
194
            return run_container_contains_range(const_CAST_run(c), range_start,
590
194
                                                range_end);
591
0
        default:
592
0
            assert(false);
593
0
            roaring_unreachable;
594
0
            return false;
595
516
    }
596
516
}
Unexecuted instantiation: roaring_array.c:container_contains_range
Unexecuted instantiation: containers.c:container_contains_range
Unexecuted instantiation: convert.c:container_contains_range
Unexecuted instantiation: mixed_negation.c:container_contains_range
Unexecuted instantiation: mixed_xor.c:container_contains_range
Unexecuted instantiation: mixed_andnot.c:container_contains_range
Unexecuted instantiation: roaring64.c:container_contains_range
597
598
/**
599
 * Returns true if the two containers have the same content. Note that
600
 * two containers having different types can be "equal" in this sense.
601
 */
602
static inline bool container_equals(const container_t *c1, uint8_t type1,
603
88.2k
                                    const container_t *c2, uint8_t type2) {
604
88.2k
    c1 = container_unwrap_shared(c1, &type1);
605
88.2k
    c2 = container_unwrap_shared(c2, &type2);
606
88.2k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
607
79.1k
        case CONTAINER_PAIR(BITSET, BITSET):
608
79.1k
            return bitset_container_equals(const_CAST_bitset(c1),
609
79.1k
                                           const_CAST_bitset(c2));
610
611
0
        case CONTAINER_PAIR(BITSET, RUN):
612
0
            return run_container_equals_bitset(const_CAST_run(c2),
613
0
                                               const_CAST_bitset(c1));
614
615
0
        case CONTAINER_PAIR(RUN, BITSET):
616
0
            return run_container_equals_bitset(const_CAST_run(c1),
617
0
                                               const_CAST_bitset(c2));
618
619
0
        case CONTAINER_PAIR(BITSET, ARRAY):
620
            // java would always return false?
621
0
            return array_container_equal_bitset(const_CAST_array(c2),
622
0
                                                const_CAST_bitset(c1));
623
624
250
        case CONTAINER_PAIR(ARRAY, BITSET):
625
            // java would always return false?
626
250
            return array_container_equal_bitset(const_CAST_array(c1),
627
250
                                                const_CAST_bitset(c2));
628
629
499
        case CONTAINER_PAIR(ARRAY, RUN):
630
499
            return run_container_equals_array(const_CAST_run(c2),
631
499
                                              const_CAST_array(c1));
632
633
205
        case CONTAINER_PAIR(RUN, ARRAY):
634
205
            return run_container_equals_array(const_CAST_run(c1),
635
205
                                              const_CAST_array(c2));
636
637
8.05k
        case CONTAINER_PAIR(ARRAY, ARRAY):
638
8.05k
            return array_container_equals(const_CAST_array(c1),
639
8.05k
                                          const_CAST_array(c2));
640
641
108
        case CONTAINER_PAIR(RUN, RUN):
642
108
            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
643
644
0
        default:
645
0
            assert(false);
646
0
            roaring_unreachable;
647
0
            return false;
648
88.2k
    }
649
88.2k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_equals(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char)
roaring.c:container_equals
Line
Count
Source
603
88.2k
                                    const container_t *c2, uint8_t type2) {
604
88.2k
    c1 = container_unwrap_shared(c1, &type1);
605
88.2k
    c2 = container_unwrap_shared(c2, &type2);
606
88.2k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
607
79.1k
        case CONTAINER_PAIR(BITSET, BITSET):
608
79.1k
            return bitset_container_equals(const_CAST_bitset(c1),
609
79.1k
                                           const_CAST_bitset(c2));
610
611
0
        case CONTAINER_PAIR(BITSET, RUN):
612
0
            return run_container_equals_bitset(const_CAST_run(c2),
613
0
                                               const_CAST_bitset(c1));
614
615
0
        case CONTAINER_PAIR(RUN, BITSET):
616
0
            return run_container_equals_bitset(const_CAST_run(c1),
617
0
                                               const_CAST_bitset(c2));
618
619
0
        case CONTAINER_PAIR(BITSET, ARRAY):
620
            // java would always return false?
621
0
            return array_container_equal_bitset(const_CAST_array(c2),
622
0
                                                const_CAST_bitset(c1));
623
624
250
        case CONTAINER_PAIR(ARRAY, BITSET):
625
            // java would always return false?
626
250
            return array_container_equal_bitset(const_CAST_array(c1),
627
250
                                                const_CAST_bitset(c2));
628
629
499
        case CONTAINER_PAIR(ARRAY, RUN):
630
499
            return run_container_equals_array(const_CAST_run(c2),
631
499
                                              const_CAST_array(c1));
632
633
205
        case CONTAINER_PAIR(RUN, ARRAY):
634
205
            return run_container_equals_array(const_CAST_run(c1),
635
205
                                              const_CAST_array(c2));
636
637
8.05k
        case CONTAINER_PAIR(ARRAY, ARRAY):
638
8.05k
            return array_container_equals(const_CAST_array(c1),
639
8.05k
                                          const_CAST_array(c2));
640
641
108
        case CONTAINER_PAIR(RUN, RUN):
642
108
            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
643
644
0
        default:
645
0
            assert(false);
646
0
            roaring_unreachable;
647
0
            return false;
648
88.2k
    }
649
88.2k
}
Unexecuted instantiation: roaring_array.c:container_equals
Unexecuted instantiation: containers.c:container_equals
Unexecuted instantiation: convert.c:container_equals
Unexecuted instantiation: mixed_negation.c:container_equals
Unexecuted instantiation: mixed_xor.c:container_equals
Unexecuted instantiation: mixed_andnot.c:container_equals
Unexecuted instantiation: roaring64.c:container_equals
650
651
/**
652
 * Returns true if the container c1 is a subset of the container c2. Note that
653
 * c1 can be a subset of c2 even if they have a different type.
654
 */
655
static inline bool container_is_subset(const container_t *c1, uint8_t type1,
656
9.17k
                                       const container_t *c2, uint8_t type2) {
657
9.17k
    c1 = container_unwrap_shared(c1, &type1);
658
9.17k
    c2 = container_unwrap_shared(c2, &type2);
659
9.17k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
660
0
        case CONTAINER_PAIR(BITSET, BITSET):
661
0
            return bitset_container_is_subset(const_CAST_bitset(c1),
662
0
                                              const_CAST_bitset(c2));
663
664
0
        case CONTAINER_PAIR(BITSET, RUN):
665
0
            return bitset_container_is_subset_run(const_CAST_bitset(c1),
666
0
                                                  const_CAST_run(c2));
667
668
0
        case CONTAINER_PAIR(RUN, BITSET):
669
0
            return run_container_is_subset_bitset(const_CAST_run(c1),
670
0
                                                  const_CAST_bitset(c2));
671
672
0
        case CONTAINER_PAIR(BITSET, ARRAY):
673
0
            return false;  // by construction, size(c1) > size(c2)
674
675
1.84k
        case CONTAINER_PAIR(ARRAY, BITSET):
676
1.84k
            return array_container_is_subset_bitset(const_CAST_array(c1),
677
1.84k
                                                    const_CAST_bitset(c2));
678
679
1.92k
        case CONTAINER_PAIR(ARRAY, RUN):
680
1.92k
            return array_container_is_subset_run(const_CAST_array(c1),
681
1.92k
                                                 const_CAST_run(c2));
682
683
281
        case CONTAINER_PAIR(RUN, ARRAY):
684
281
            return run_container_is_subset_array(const_CAST_run(c1),
685
281
                                                 const_CAST_array(c2));
686
687
4.90k
        case CONTAINER_PAIR(ARRAY, ARRAY):
688
4.90k
            return array_container_is_subset(const_CAST_array(c1),
689
4.90k
                                             const_CAST_array(c2));
690
691
216
        case CONTAINER_PAIR(RUN, RUN):
692
216
            return run_container_is_subset(const_CAST_run(c1),
693
216
                                           const_CAST_run(c2));
694
695
0
        default:
696
0
            assert(false);
697
0
            roaring_unreachable;
698
0
            return false;
699
9.17k
    }
700
9.17k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_is_subset(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char)
roaring.c:container_is_subset
Line
Count
Source
656
9.17k
                                       const container_t *c2, uint8_t type2) {
657
9.17k
    c1 = container_unwrap_shared(c1, &type1);
658
9.17k
    c2 = container_unwrap_shared(c2, &type2);
659
9.17k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
660
0
        case CONTAINER_PAIR(BITSET, BITSET):
661
0
            return bitset_container_is_subset(const_CAST_bitset(c1),
662
0
                                              const_CAST_bitset(c2));
663
664
0
        case CONTAINER_PAIR(BITSET, RUN):
665
0
            return bitset_container_is_subset_run(const_CAST_bitset(c1),
666
0
                                                  const_CAST_run(c2));
667
668
0
        case CONTAINER_PAIR(RUN, BITSET):
669
0
            return run_container_is_subset_bitset(const_CAST_run(c1),
670
0
                                                  const_CAST_bitset(c2));
671
672
0
        case CONTAINER_PAIR(BITSET, ARRAY):
673
0
            return false;  // by construction, size(c1) > size(c2)
674
675
1.84k
        case CONTAINER_PAIR(ARRAY, BITSET):
676
1.84k
            return array_container_is_subset_bitset(const_CAST_array(c1),
677
1.84k
                                                    const_CAST_bitset(c2));
678
679
1.92k
        case CONTAINER_PAIR(ARRAY, RUN):
680
1.92k
            return array_container_is_subset_run(const_CAST_array(c1),
681
1.92k
                                                 const_CAST_run(c2));
682
683
281
        case CONTAINER_PAIR(RUN, ARRAY):
684
281
            return run_container_is_subset_array(const_CAST_run(c1),
685
281
                                                 const_CAST_array(c2));
686
687
4.90k
        case CONTAINER_PAIR(ARRAY, ARRAY):
688
4.90k
            return array_container_is_subset(const_CAST_array(c1),
689
4.90k
                                             const_CAST_array(c2));
690
691
216
        case CONTAINER_PAIR(RUN, RUN):
692
216
            return run_container_is_subset(const_CAST_run(c1),
693
216
                                           const_CAST_run(c2));
694
695
0
        default:
696
0
            assert(false);
697
0
            roaring_unreachable;
698
0
            return false;
699
9.17k
    }
700
9.17k
}
Unexecuted instantiation: roaring_array.c:container_is_subset
Unexecuted instantiation: containers.c:container_is_subset
Unexecuted instantiation: convert.c:container_is_subset
Unexecuted instantiation: mixed_negation.c:container_is_subset
Unexecuted instantiation: mixed_xor.c:container_is_subset
Unexecuted instantiation: mixed_andnot.c:container_is_subset
Unexecuted instantiation: roaring64.c:container_is_subset
701
702
// macro-izations possibilities for generic non-inplace binary-op dispatch
703
704
/**
705
 * Compute intersection between two containers, generate a new container (having
706
 * type result_type), requires a typecode. This allocates new memory, caller
707
 * is responsible for deallocation.
708
 */
709
static inline container_t *container_and(const container_t *c1, uint8_t type1,
710
                                         const container_t *c2, uint8_t type2,
711
5.24k
                                         uint8_t *result_type) {
712
5.24k
    c1 = container_unwrap_shared(c1, &type1);
713
5.24k
    c2 = container_unwrap_shared(c2, &type2);
714
5.24k
    container_t *result = NULL;
715
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
716
0
        case CONTAINER_PAIR(BITSET, BITSET):
717
0
            *result_type =
718
0
                bitset_bitset_container_intersection(
719
0
                    const_CAST_bitset(c1), const_CAST_bitset(c2), &result)
720
0
                    ? BITSET_CONTAINER_TYPE
721
0
                    : ARRAY_CONTAINER_TYPE;
722
0
            return result;
723
724
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
725
1.99k
            result = array_container_create();
726
1.99k
            array_container_intersection(
727
1.99k
                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
728
1.99k
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
729
1.99k
            return result;
730
731
576
        case CONTAINER_PAIR(RUN, RUN):
732
576
            result = run_container_create();
733
576
            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
734
576
                                       CAST_run(result));
735
576
            return convert_run_to_efficient_container_and_free(CAST_run(result),
736
576
                                                               result_type);
737
738
0
        case CONTAINER_PAIR(BITSET, ARRAY):
739
0
            result = array_container_create();
740
0
            array_bitset_container_intersection(const_CAST_array(c2),
741
0
                                                const_CAST_bitset(c1),
742
0
                                                CAST_array(result));
743
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
744
0
            return result;
745
746
513
        case CONTAINER_PAIR(ARRAY, BITSET):
747
513
            result = array_container_create();
748
513
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
749
513
            array_bitset_container_intersection(const_CAST_array(c1),
750
513
                                                const_CAST_bitset(c2),
751
513
                                                CAST_array(result));
752
513
            return result;
753
754
0
        case CONTAINER_PAIR(BITSET, RUN):
755
0
            *result_type =
756
0
                run_bitset_container_intersection(
757
0
                    const_CAST_run(c2), const_CAST_bitset(c1), &result)
758
0
                    ? BITSET_CONTAINER_TYPE
759
0
                    : ARRAY_CONTAINER_TYPE;
760
0
            return result;
761
762
443
        case CONTAINER_PAIR(RUN, BITSET):
763
443
            *result_type =
764
443
                run_bitset_container_intersection(
765
443
                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
766
443
                    ? BITSET_CONTAINER_TYPE
767
443
                    : ARRAY_CONTAINER_TYPE;
768
443
            return result;
769
770
693
        case CONTAINER_PAIR(ARRAY, RUN):
771
693
            result = array_container_create();
772
693
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
773
693
            array_run_container_intersection(
774
693
                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
775
693
            return result;
776
777
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
778
1.02k
            result = array_container_create();
779
1.02k
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
780
1.02k
            array_run_container_intersection(
781
1.02k
                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
782
1.02k
            return result;
783
784
0
        default:
785
0
            assert(false);
786
0
            roaring_unreachable;
787
0
            return NULL;
788
5.24k
    }
789
5.24k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_and(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_and
Line
Count
Source
711
5.24k
                                         uint8_t *result_type) {
712
5.24k
    c1 = container_unwrap_shared(c1, &type1);
713
5.24k
    c2 = container_unwrap_shared(c2, &type2);
714
5.24k
    container_t *result = NULL;
715
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
716
0
        case CONTAINER_PAIR(BITSET, BITSET):
717
0
            *result_type =
718
0
                bitset_bitset_container_intersection(
719
0
                    const_CAST_bitset(c1), const_CAST_bitset(c2), &result)
720
0
                    ? BITSET_CONTAINER_TYPE
721
0
                    : ARRAY_CONTAINER_TYPE;
722
0
            return result;
723
724
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
725
1.99k
            result = array_container_create();
726
1.99k
            array_container_intersection(
727
1.99k
                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
728
1.99k
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
729
1.99k
            return result;
730
731
576
        case CONTAINER_PAIR(RUN, RUN):
732
576
            result = run_container_create();
733
576
            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
734
576
                                       CAST_run(result));
735
576
            return convert_run_to_efficient_container_and_free(CAST_run(result),
736
576
                                                               result_type);
737
738
0
        case CONTAINER_PAIR(BITSET, ARRAY):
739
0
            result = array_container_create();
740
0
            array_bitset_container_intersection(const_CAST_array(c2),
741
0
                                                const_CAST_bitset(c1),
742
0
                                                CAST_array(result));
743
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
744
0
            return result;
745
746
513
        case CONTAINER_PAIR(ARRAY, BITSET):
747
513
            result = array_container_create();
748
513
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
749
513
            array_bitset_container_intersection(const_CAST_array(c1),
750
513
                                                const_CAST_bitset(c2),
751
513
                                                CAST_array(result));
752
513
            return result;
753
754
0
        case CONTAINER_PAIR(BITSET, RUN):
755
0
            *result_type =
756
0
                run_bitset_container_intersection(
757
0
                    const_CAST_run(c2), const_CAST_bitset(c1), &result)
758
0
                    ? BITSET_CONTAINER_TYPE
759
0
                    : ARRAY_CONTAINER_TYPE;
760
0
            return result;
761
762
443
        case CONTAINER_PAIR(RUN, BITSET):
763
443
            *result_type =
764
443
                run_bitset_container_intersection(
765
443
                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
766
443
                    ? BITSET_CONTAINER_TYPE
767
443
                    : ARRAY_CONTAINER_TYPE;
768
443
            return result;
769
770
693
        case CONTAINER_PAIR(ARRAY, RUN):
771
693
            result = array_container_create();
772
693
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
773
693
            array_run_container_intersection(
774
693
                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
775
693
            return result;
776
777
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
778
1.02k
            result = array_container_create();
779
1.02k
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
780
1.02k
            array_run_container_intersection(
781
1.02k
                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
782
1.02k
            return result;
783
784
0
        default:
785
0
            assert(false);
786
0
            roaring_unreachable;
787
0
            return NULL;
788
5.24k
    }
789
5.24k
}
Unexecuted instantiation: roaring_array.c:container_and
Unexecuted instantiation: containers.c:container_and
Unexecuted instantiation: convert.c:container_and
Unexecuted instantiation: mixed_negation.c:container_and
Unexecuted instantiation: mixed_xor.c:container_and
Unexecuted instantiation: mixed_andnot.c:container_and
Unexecuted instantiation: roaring64.c:container_and
790
791
/**
792
 * Compute the size of the intersection between two containers.
793
 */
794
static inline int container_and_cardinality(const container_t *c1,
795
                                            uint8_t type1,
796
                                            const container_t *c2,
797
20.9k
                                            uint8_t type2) {
798
20.9k
    c1 = container_unwrap_shared(c1, &type1);
799
20.9k
    c2 = container_unwrap_shared(c2, &type2);
800
20.9k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
801
0
        case CONTAINER_PAIR(BITSET, BITSET):
802
0
            return bitset_container_and_justcard(const_CAST_bitset(c1),
803
0
                                                 const_CAST_bitset(c2));
804
805
7.96k
        case CONTAINER_PAIR(ARRAY, ARRAY):
806
7.96k
            return array_container_intersection_cardinality(
807
7.96k
                const_CAST_array(c1), const_CAST_array(c2));
808
809
2.30k
        case CONTAINER_PAIR(RUN, RUN):
810
2.30k
            return run_container_intersection_cardinality(const_CAST_run(c1),
811
2.30k
                                                          const_CAST_run(c2));
812
813
0
        case CONTAINER_PAIR(BITSET, ARRAY):
814
0
            return array_bitset_container_intersection_cardinality(
815
0
                const_CAST_array(c2), const_CAST_bitset(c1));
816
817
2.05k
        case CONTAINER_PAIR(ARRAY, BITSET):
818
2.05k
            return array_bitset_container_intersection_cardinality(
819
2.05k
                const_CAST_array(c1), const_CAST_bitset(c2));
820
821
0
        case CONTAINER_PAIR(BITSET, RUN):
822
0
            return run_bitset_container_intersection_cardinality(
823
0
                const_CAST_run(c2), const_CAST_bitset(c1));
824
825
1.77k
        case CONTAINER_PAIR(RUN, BITSET):
826
1.77k
            return run_bitset_container_intersection_cardinality(
827
1.77k
                const_CAST_run(c1), const_CAST_bitset(c2));
828
829
2.77k
        case CONTAINER_PAIR(ARRAY, RUN):
830
2.77k
            return array_run_container_intersection_cardinality(
831
2.77k
                const_CAST_array(c1), const_CAST_run(c2));
832
833
4.10k
        case CONTAINER_PAIR(RUN, ARRAY):
834
4.10k
            return array_run_container_intersection_cardinality(
835
4.10k
                const_CAST_array(c2), const_CAST_run(c1));
836
837
0
        default:
838
0
            assert(false);
839
0
            roaring_unreachable;
840
0
            return 0;
841
20.9k
    }
842
20.9k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_and_cardinality(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char)
roaring.c:container_and_cardinality
Line
Count
Source
797
20.9k
                                            uint8_t type2) {
798
20.9k
    c1 = container_unwrap_shared(c1, &type1);
799
20.9k
    c2 = container_unwrap_shared(c2, &type2);
800
20.9k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
801
0
        case CONTAINER_PAIR(BITSET, BITSET):
802
0
            return bitset_container_and_justcard(const_CAST_bitset(c1),
803
0
                                                 const_CAST_bitset(c2));
804
805
7.96k
        case CONTAINER_PAIR(ARRAY, ARRAY):
806
7.96k
            return array_container_intersection_cardinality(
807
7.96k
                const_CAST_array(c1), const_CAST_array(c2));
808
809
2.30k
        case CONTAINER_PAIR(RUN, RUN):
810
2.30k
            return run_container_intersection_cardinality(const_CAST_run(c1),
811
2.30k
                                                          const_CAST_run(c2));
812
813
0
        case CONTAINER_PAIR(BITSET, ARRAY):
814
0
            return array_bitset_container_intersection_cardinality(
815
0
                const_CAST_array(c2), const_CAST_bitset(c1));
816
817
2.05k
        case CONTAINER_PAIR(ARRAY, BITSET):
818
2.05k
            return array_bitset_container_intersection_cardinality(
819
2.05k
                const_CAST_array(c1), const_CAST_bitset(c2));
820
821
0
        case CONTAINER_PAIR(BITSET, RUN):
822
0
            return run_bitset_container_intersection_cardinality(
823
0
                const_CAST_run(c2), const_CAST_bitset(c1));
824
825
1.77k
        case CONTAINER_PAIR(RUN, BITSET):
826
1.77k
            return run_bitset_container_intersection_cardinality(
827
1.77k
                const_CAST_run(c1), const_CAST_bitset(c2));
828
829
2.77k
        case CONTAINER_PAIR(ARRAY, RUN):
830
2.77k
            return array_run_container_intersection_cardinality(
831
2.77k
                const_CAST_array(c1), const_CAST_run(c2));
832
833
4.10k
        case CONTAINER_PAIR(RUN, ARRAY):
834
4.10k
            return array_run_container_intersection_cardinality(
835
4.10k
                const_CAST_array(c2), const_CAST_run(c1));
836
837
0
        default:
838
0
            assert(false);
839
0
            roaring_unreachable;
840
0
            return 0;
841
20.9k
    }
842
20.9k
}
Unexecuted instantiation: roaring_array.c:container_and_cardinality
Unexecuted instantiation: containers.c:container_and_cardinality
Unexecuted instantiation: convert.c:container_and_cardinality
Unexecuted instantiation: mixed_negation.c:container_and_cardinality
Unexecuted instantiation: mixed_xor.c:container_and_cardinality
Unexecuted instantiation: mixed_andnot.c:container_and_cardinality
Unexecuted instantiation: roaring64.c:container_and_cardinality
843
844
/**
845
 * Check whether two containers intersect.
846
 */
847
static inline bool container_intersect(const container_t *c1, uint8_t type1,
848
5.24k
                                       const container_t *c2, uint8_t type2) {
849
5.24k
    c1 = container_unwrap_shared(c1, &type1);
850
5.24k
    c2 = container_unwrap_shared(c2, &type2);
851
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
852
0
        case CONTAINER_PAIR(BITSET, BITSET):
853
0
            return bitset_container_intersect(const_CAST_bitset(c1),
854
0
                                              const_CAST_bitset(c2));
855
856
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
857
1.99k
            return array_container_intersect(const_CAST_array(c1),
858
1.99k
                                             const_CAST_array(c2));
859
860
576
        case CONTAINER_PAIR(RUN, RUN):
861
576
            return run_container_intersect(const_CAST_run(c1),
862
576
                                           const_CAST_run(c2));
863
864
0
        case CONTAINER_PAIR(BITSET, ARRAY):
865
0
            return array_bitset_container_intersect(const_CAST_array(c2),
866
0
                                                    const_CAST_bitset(c1));
867
868
513
        case CONTAINER_PAIR(ARRAY, BITSET):
869
513
            return array_bitset_container_intersect(const_CAST_array(c1),
870
513
                                                    const_CAST_bitset(c2));
871
872
0
        case CONTAINER_PAIR(BITSET, RUN):
873
0
            return run_bitset_container_intersect(const_CAST_run(c2),
874
0
                                                  const_CAST_bitset(c1));
875
876
443
        case CONTAINER_PAIR(RUN, BITSET):
877
443
            return run_bitset_container_intersect(const_CAST_run(c1),
878
443
                                                  const_CAST_bitset(c2));
879
880
693
        case CONTAINER_PAIR(ARRAY, RUN):
881
693
            return array_run_container_intersect(const_CAST_array(c1),
882
693
                                                 const_CAST_run(c2));
883
884
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
885
1.02k
            return array_run_container_intersect(const_CAST_array(c2),
886
1.02k
                                                 const_CAST_run(c1));
887
888
0
        default:
889
0
            assert(false);
890
0
            roaring_unreachable;
891
0
            return 0;
892
5.24k
    }
893
5.24k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_intersect(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char)
roaring.c:container_intersect
Line
Count
Source
848
5.24k
                                       const container_t *c2, uint8_t type2) {
849
5.24k
    c1 = container_unwrap_shared(c1, &type1);
850
5.24k
    c2 = container_unwrap_shared(c2, &type2);
851
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
852
0
        case CONTAINER_PAIR(BITSET, BITSET):
853
0
            return bitset_container_intersect(const_CAST_bitset(c1),
854
0
                                              const_CAST_bitset(c2));
855
856
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
857
1.99k
            return array_container_intersect(const_CAST_array(c1),
858
1.99k
                                             const_CAST_array(c2));
859
860
576
        case CONTAINER_PAIR(RUN, RUN):
861
576
            return run_container_intersect(const_CAST_run(c1),
862
576
                                           const_CAST_run(c2));
863
864
0
        case CONTAINER_PAIR(BITSET, ARRAY):
865
0
            return array_bitset_container_intersect(const_CAST_array(c2),
866
0
                                                    const_CAST_bitset(c1));
867
868
513
        case CONTAINER_PAIR(ARRAY, BITSET):
869
513
            return array_bitset_container_intersect(const_CAST_array(c1),
870
513
                                                    const_CAST_bitset(c2));
871
872
0
        case CONTAINER_PAIR(BITSET, RUN):
873
0
            return run_bitset_container_intersect(const_CAST_run(c2),
874
0
                                                  const_CAST_bitset(c1));
875
876
443
        case CONTAINER_PAIR(RUN, BITSET):
877
443
            return run_bitset_container_intersect(const_CAST_run(c1),
878
443
                                                  const_CAST_bitset(c2));
879
880
693
        case CONTAINER_PAIR(ARRAY, RUN):
881
693
            return array_run_container_intersect(const_CAST_array(c1),
882
693
                                                 const_CAST_run(c2));
883
884
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
885
1.02k
            return array_run_container_intersect(const_CAST_array(c2),
886
1.02k
                                                 const_CAST_run(c1));
887
888
0
        default:
889
0
            assert(false);
890
0
            roaring_unreachable;
891
0
            return 0;
892
5.24k
    }
893
5.24k
}
Unexecuted instantiation: roaring_array.c:container_intersect
Unexecuted instantiation: containers.c:container_intersect
Unexecuted instantiation: convert.c:container_intersect
Unexecuted instantiation: mixed_negation.c:container_intersect
Unexecuted instantiation: mixed_xor.c:container_intersect
Unexecuted instantiation: mixed_andnot.c:container_intersect
Unexecuted instantiation: roaring64.c:container_intersect
894
895
/**
896
 * Compute intersection between two containers, with result in the first
897
 container if possible. If the returned pointer is identical to c1,
898
 then the container has been modified. If the returned pointer is different
899
 from c1, then a new container has been created and the caller is responsible
900
 for freeing it.
901
 The type of the first container may change. Returns the modified
902
 (and possibly new) container.
903
*/
904
static inline container_t *container_iand(container_t *c1, uint8_t type1,
905
                                          const container_t *c2, uint8_t type2,
906
71.9k
                                          uint8_t *result_type) {
907
71.9k
    c1 = get_writable_copy_if_shared(c1, &type1);
908
71.9k
    c2 = container_unwrap_shared(c2, &type2);
909
71.9k
    container_t *result = NULL;
910
71.9k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
911
1.21k
        case CONTAINER_PAIR(BITSET, BITSET):
912
1.21k
            *result_type = bitset_bitset_container_intersection_inplace(
913
1.21k
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
914
1.21k
                               ? BITSET_CONTAINER_TYPE
915
1.21k
                               : ARRAY_CONTAINER_TYPE;
916
1.21k
            return result;
917
918
4.10k
        case CONTAINER_PAIR(ARRAY, ARRAY):
919
4.10k
            array_container_intersection_inplace(CAST_array(c1),
920
4.10k
                                                 const_CAST_array(c2));
921
4.10k
            *result_type = ARRAY_CONTAINER_TYPE;
922
4.10k
            return c1;
923
924
65.5k
        case CONTAINER_PAIR(RUN, RUN):
925
65.5k
            result = run_container_create();
926
65.5k
            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
927
65.5k
                                       CAST_run(result));
928
            // as of January 2016, Java code used non-in-place intersection for
929
            // two runcontainers
930
65.5k
            return convert_run_to_efficient_container_and_free(CAST_run(result),
931
65.5k
                                                               result_type);
932
933
60
        case CONTAINER_PAIR(BITSET, ARRAY):
934
            // c1 is a bitmap so no inplace possible
935
60
            result = array_container_create();
936
60
            array_bitset_container_intersection(const_CAST_array(c2),
937
60
                                                const_CAST_bitset(c1),
938
60
                                                CAST_array(result));
939
60
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
940
60
            return result;
941
942
0
        case CONTAINER_PAIR(ARRAY, BITSET):
943
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
944
0
            array_bitset_container_intersection(
945
0
                const_CAST_array(c1), const_CAST_bitset(c2),
946
0
                CAST_array(c1));  // result is allowed to be same as c1
947
0
            return c1;
948
949
0
        case CONTAINER_PAIR(BITSET, RUN):
950
            // will attempt in-place computation
951
0
            *result_type = run_bitset_container_intersection(
952
0
                               const_CAST_run(c2), const_CAST_bitset(c1), &c1)
953
0
                               ? BITSET_CONTAINER_TYPE
954
0
                               : ARRAY_CONTAINER_TYPE;
955
0
            return c1;
956
957
0
        case CONTAINER_PAIR(RUN, BITSET):
958
0
            *result_type =
959
0
                run_bitset_container_intersection(
960
0
                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
961
0
                    ? BITSET_CONTAINER_TYPE
962
0
                    : ARRAY_CONTAINER_TYPE;
963
0
            return result;
964
965
150
        case CONTAINER_PAIR(ARRAY, RUN):
966
150
            result = array_container_create();
967
150
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
968
150
            array_run_container_intersection(
969
150
                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
970
150
            return result;
971
972
862
        case CONTAINER_PAIR(RUN, ARRAY):
973
862
            result = array_container_create();
974
862
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
975
862
            array_run_container_intersection(
976
862
                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
977
862
            return result;
978
979
0
        default:
980
0
            assert(false);
981
0
            roaring_unreachable;
982
0
            return NULL;
983
71.9k
    }
984
71.9k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_iand(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_iand
Line
Count
Source
906
71.9k
                                          uint8_t *result_type) {
907
71.9k
    c1 = get_writable_copy_if_shared(c1, &type1);
908
71.9k
    c2 = container_unwrap_shared(c2, &type2);
909
71.9k
    container_t *result = NULL;
910
71.9k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
911
1.21k
        case CONTAINER_PAIR(BITSET, BITSET):
912
1.21k
            *result_type = bitset_bitset_container_intersection_inplace(
913
1.21k
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
914
1.21k
                               ? BITSET_CONTAINER_TYPE
915
1.21k
                               : ARRAY_CONTAINER_TYPE;
916
1.21k
            return result;
917
918
4.10k
        case CONTAINER_PAIR(ARRAY, ARRAY):
919
4.10k
            array_container_intersection_inplace(CAST_array(c1),
920
4.10k
                                                 const_CAST_array(c2));
921
4.10k
            *result_type = ARRAY_CONTAINER_TYPE;
922
4.10k
            return c1;
923
924
65.5k
        case CONTAINER_PAIR(RUN, RUN):
925
65.5k
            result = run_container_create();
926
65.5k
            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
927
65.5k
                                       CAST_run(result));
928
            // as of January 2016, Java code used non-in-place intersection for
929
            // two runcontainers
930
65.5k
            return convert_run_to_efficient_container_and_free(CAST_run(result),
931
65.5k
                                                               result_type);
932
933
60
        case CONTAINER_PAIR(BITSET, ARRAY):
934
            // c1 is a bitmap so no inplace possible
935
60
            result = array_container_create();
936
60
            array_bitset_container_intersection(const_CAST_array(c2),
937
60
                                                const_CAST_bitset(c1),
938
60
                                                CAST_array(result));
939
60
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
940
60
            return result;
941
942
0
        case CONTAINER_PAIR(ARRAY, BITSET):
943
0
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
944
0
            array_bitset_container_intersection(
945
0
                const_CAST_array(c1), const_CAST_bitset(c2),
946
0
                CAST_array(c1));  // result is allowed to be same as c1
947
0
            return c1;
948
949
0
        case CONTAINER_PAIR(BITSET, RUN):
950
            // will attempt in-place computation
951
0
            *result_type = run_bitset_container_intersection(
952
0
                               const_CAST_run(c2), const_CAST_bitset(c1), &c1)
953
0
                               ? BITSET_CONTAINER_TYPE
954
0
                               : ARRAY_CONTAINER_TYPE;
955
0
            return c1;
956
957
0
        case CONTAINER_PAIR(RUN, BITSET):
958
0
            *result_type =
959
0
                run_bitset_container_intersection(
960
0
                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
961
0
                    ? BITSET_CONTAINER_TYPE
962
0
                    : ARRAY_CONTAINER_TYPE;
963
0
            return result;
964
965
150
        case CONTAINER_PAIR(ARRAY, RUN):
966
150
            result = array_container_create();
967
150
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
968
150
            array_run_container_intersection(
969
150
                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
970
150
            return result;
971
972
862
        case CONTAINER_PAIR(RUN, ARRAY):
973
862
            result = array_container_create();
974
862
            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
975
862
            array_run_container_intersection(
976
862
                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
977
862
            return result;
978
979
0
        default:
980
0
            assert(false);
981
0
            roaring_unreachable;
982
0
            return NULL;
983
71.9k
    }
984
71.9k
}
Unexecuted instantiation: roaring_array.c:container_iand
Unexecuted instantiation: containers.c:container_iand
Unexecuted instantiation: convert.c:container_iand
Unexecuted instantiation: mixed_negation.c:container_iand
Unexecuted instantiation: mixed_xor.c:container_iand
Unexecuted instantiation: mixed_andnot.c:container_iand
Unexecuted instantiation: roaring64.c:container_iand
985
986
/**
987
 * Compute union between two containers, generate a new container (having type
988
 * result_type), requires a typecode. This allocates new memory, caller
989
 * is responsible for deallocation.
990
 */
991
static inline container_t *container_or(const container_t *c1, uint8_t type1,
992
                                        const container_t *c2, uint8_t type2,
993
5.24k
                                        uint8_t *result_type) {
994
5.24k
    c1 = container_unwrap_shared(c1, &type1);
995
5.24k
    c2 = container_unwrap_shared(c2, &type2);
996
5.24k
    container_t *result = NULL;
997
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
998
0
        case CONTAINER_PAIR(BITSET, BITSET):
999
0
            result = bitset_container_create();
1000
0
            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
1001
0
                                CAST_bitset(result));
1002
0
            *result_type = BITSET_CONTAINER_TYPE;
1003
0
            return result;
1004
1005
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1006
1.99k
            *result_type =
1007
1.99k
                array_array_container_union(const_CAST_array(c1),
1008
1.99k
                                            const_CAST_array(c2), &result)
1009
1.99k
                    ? BITSET_CONTAINER_TYPE
1010
1.99k
                    : ARRAY_CONTAINER_TYPE;
1011
1.99k
            return result;
1012
1013
576
        case CONTAINER_PAIR(RUN, RUN):
1014
576
            result = run_container_create();
1015
576
            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
1016
576
                                CAST_run(result));
1017
576
            *result_type = RUN_CONTAINER_TYPE;
1018
            // todo: could be optimized since will never convert to array
1019
576
            result = convert_run_to_efficient_container_and_free(
1020
576
                CAST_run(result), result_type);
1021
576
            return result;
1022
1023
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1024
0
            result = bitset_container_create();
1025
0
            array_bitset_container_union(const_CAST_array(c2),
1026
0
                                         const_CAST_bitset(c1),
1027
0
                                         CAST_bitset(result));
1028
0
            *result_type = BITSET_CONTAINER_TYPE;
1029
0
            return result;
1030
1031
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1032
513
            result = bitset_container_create();
1033
513
            array_bitset_container_union(const_CAST_array(c1),
1034
513
                                         const_CAST_bitset(c2),
1035
513
                                         CAST_bitset(result));
1036
513
            *result_type = BITSET_CONTAINER_TYPE;
1037
513
            return result;
1038
1039
0
        case CONTAINER_PAIR(BITSET, RUN):
1040
0
            if (run_container_is_full(const_CAST_run(c2))) {
1041
0
                result = run_container_create();
1042
0
                *result_type = RUN_CONTAINER_TYPE;
1043
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1044
0
                return result;
1045
0
            }
1046
0
            result = bitset_container_create();
1047
0
            run_bitset_container_union(
1048
0
                const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
1049
0
            *result_type = BITSET_CONTAINER_TYPE;
1050
0
            return result;
1051
1052
443
        case CONTAINER_PAIR(RUN, BITSET):
1053
443
            if (run_container_is_full(const_CAST_run(c1))) {
1054
0
                result = run_container_create();
1055
0
                *result_type = RUN_CONTAINER_TYPE;
1056
0
                run_container_copy(const_CAST_run(c1), CAST_run(result));
1057
0
                return result;
1058
0
            }
1059
443
            result = bitset_container_create();
1060
443
            run_bitset_container_union(
1061
443
                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
1062
443
            *result_type = BITSET_CONTAINER_TYPE;
1063
443
            return result;
1064
1065
693
        case CONTAINER_PAIR(ARRAY, RUN):
1066
693
            result = run_container_create();
1067
693
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1068
693
                                      CAST_run(result));
1069
693
            result = convert_run_to_efficient_container_and_free(
1070
693
                CAST_run(result), result_type);
1071
693
            return result;
1072
1073
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1074
1.02k
            result = run_container_create();
1075
1.02k
            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
1076
1.02k
                                      CAST_run(result));
1077
1.02k
            result = convert_run_to_efficient_container_and_free(
1078
1.02k
                CAST_run(result), result_type);
1079
1.02k
            return result;
1080
1081
0
        default:
1082
0
            assert(false);
1083
0
            roaring_unreachable;
1084
0
            return NULL;  // unreached
1085
5.24k
    }
1086
5.24k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_or(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_or
Line
Count
Source
993
5.24k
                                        uint8_t *result_type) {
994
5.24k
    c1 = container_unwrap_shared(c1, &type1);
995
5.24k
    c2 = container_unwrap_shared(c2, &type2);
996
5.24k
    container_t *result = NULL;
997
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
998
0
        case CONTAINER_PAIR(BITSET, BITSET):
999
0
            result = bitset_container_create();
1000
0
            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
1001
0
                                CAST_bitset(result));
1002
0
            *result_type = BITSET_CONTAINER_TYPE;
1003
0
            return result;
1004
1005
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1006
1.99k
            *result_type =
1007
1.99k
                array_array_container_union(const_CAST_array(c1),
1008
1.99k
                                            const_CAST_array(c2), &result)
1009
1.99k
                    ? BITSET_CONTAINER_TYPE
1010
1.99k
                    : ARRAY_CONTAINER_TYPE;
1011
1.99k
            return result;
1012
1013
576
        case CONTAINER_PAIR(RUN, RUN):
1014
576
            result = run_container_create();
1015
576
            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
1016
576
                                CAST_run(result));
1017
576
            *result_type = RUN_CONTAINER_TYPE;
1018
            // todo: could be optimized since will never convert to array
1019
576
            result = convert_run_to_efficient_container_and_free(
1020
576
                CAST_run(result), result_type);
1021
576
            return result;
1022
1023
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1024
0
            result = bitset_container_create();
1025
0
            array_bitset_container_union(const_CAST_array(c2),
1026
0
                                         const_CAST_bitset(c1),
1027
0
                                         CAST_bitset(result));
1028
0
            *result_type = BITSET_CONTAINER_TYPE;
1029
0
            return result;
1030
1031
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1032
513
            result = bitset_container_create();
1033
513
            array_bitset_container_union(const_CAST_array(c1),
1034
513
                                         const_CAST_bitset(c2),
1035
513
                                         CAST_bitset(result));
1036
513
            *result_type = BITSET_CONTAINER_TYPE;
1037
513
            return result;
1038
1039
0
        case CONTAINER_PAIR(BITSET, RUN):
1040
0
            if (run_container_is_full(const_CAST_run(c2))) {
1041
0
                result = run_container_create();
1042
0
                *result_type = RUN_CONTAINER_TYPE;
1043
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1044
0
                return result;
1045
0
            }
1046
0
            result = bitset_container_create();
1047
0
            run_bitset_container_union(
1048
0
                const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
1049
0
            *result_type = BITSET_CONTAINER_TYPE;
1050
0
            return result;
1051
1052
443
        case CONTAINER_PAIR(RUN, BITSET):
1053
443
            if (run_container_is_full(const_CAST_run(c1))) {
1054
0
                result = run_container_create();
1055
0
                *result_type = RUN_CONTAINER_TYPE;
1056
0
                run_container_copy(const_CAST_run(c1), CAST_run(result));
1057
0
                return result;
1058
0
            }
1059
443
            result = bitset_container_create();
1060
443
            run_bitset_container_union(
1061
443
                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
1062
443
            *result_type = BITSET_CONTAINER_TYPE;
1063
443
            return result;
1064
1065
693
        case CONTAINER_PAIR(ARRAY, RUN):
1066
693
            result = run_container_create();
1067
693
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1068
693
                                      CAST_run(result));
1069
693
            result = convert_run_to_efficient_container_and_free(
1070
693
                CAST_run(result), result_type);
1071
693
            return result;
1072
1073
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1074
1.02k
            result = run_container_create();
1075
1.02k
            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
1076
1.02k
                                      CAST_run(result));
1077
1.02k
            result = convert_run_to_efficient_container_and_free(
1078
1.02k
                CAST_run(result), result_type);
1079
1.02k
            return result;
1080
1081
0
        default:
1082
0
            assert(false);
1083
0
            roaring_unreachable;
1084
0
            return NULL;  // unreached
1085
5.24k
    }
1086
5.24k
}
Unexecuted instantiation: roaring_array.c:container_or
Unexecuted instantiation: containers.c:container_or
Unexecuted instantiation: convert.c:container_or
Unexecuted instantiation: mixed_negation.c:container_or
Unexecuted instantiation: mixed_xor.c:container_or
Unexecuted instantiation: mixed_andnot.c:container_or
Unexecuted instantiation: roaring64.c:container_or
1087
1088
/**
1089
 * Compute union between two containers, generate a new container (having type
1090
 * result_type), requires a typecode. This allocates new memory, caller
1091
 * is responsible for deallocation.
1092
 *
1093
 * This lazy version delays some operations such as the maintenance of the
1094
 * cardinality. It requires repair later on the generated containers.
1095
 */
1096
static inline container_t *container_lazy_or(const container_t *c1,
1097
                                             uint8_t type1,
1098
                                             const container_t *c2,
1099
                                             uint8_t type2,
1100
0
                                             uint8_t *result_type) {
1101
0
    c1 = container_unwrap_shared(c1, &type1);
1102
0
    c2 = container_unwrap_shared(c2, &type2);
1103
0
    container_t *result = NULL;
1104
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1105
0
        case CONTAINER_PAIR(BITSET, BITSET):
1106
0
            result = bitset_container_create();
1107
0
            bitset_container_or_nocard(const_CAST_bitset(c1),
1108
0
                                       const_CAST_bitset(c2),
1109
0
                                       CAST_bitset(result));  // is lazy
1110
0
            *result_type = BITSET_CONTAINER_TYPE;
1111
0
            return result;
1112
1113
0
        case CONTAINER_PAIR(ARRAY, ARRAY):
1114
0
            *result_type =
1115
0
                array_array_container_lazy_union(const_CAST_array(c1),
1116
0
                                                 const_CAST_array(c2), &result)
1117
0
                    ? BITSET_CONTAINER_TYPE
1118
0
                    : ARRAY_CONTAINER_TYPE;
1119
0
            return result;
1120
1121
0
        case CONTAINER_PAIR(RUN, RUN):
1122
0
            result = run_container_create();
1123
0
            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
1124
0
                                CAST_run(result));
1125
0
            *result_type = RUN_CONTAINER_TYPE;
1126
            // we are being lazy
1127
0
            result = convert_run_to_efficient_container_and_free(
1128
0
                CAST_run(result), result_type);
1129
0
            return result;
1130
1131
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1132
0
            result = bitset_container_create();
1133
0
            array_bitset_container_lazy_union(const_CAST_array(c2),
1134
0
                                              const_CAST_bitset(c1),
1135
0
                                              CAST_bitset(result));  // is lazy
1136
0
            *result_type = BITSET_CONTAINER_TYPE;
1137
0
            return result;
1138
1139
0
        case CONTAINER_PAIR(ARRAY, BITSET):
1140
0
            result = bitset_container_create();
1141
0
            array_bitset_container_lazy_union(const_CAST_array(c1),
1142
0
                                              const_CAST_bitset(c2),
1143
0
                                              CAST_bitset(result));  // is lazy
1144
0
            *result_type = BITSET_CONTAINER_TYPE;
1145
0
            return result;
1146
1147
0
        case CONTAINER_PAIR(BITSET, RUN):
1148
0
            if (run_container_is_full(const_CAST_run(c2))) {
1149
0
                result = run_container_create();
1150
0
                *result_type = RUN_CONTAINER_TYPE;
1151
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1152
0
                return result;
1153
0
            }
1154
0
            result = bitset_container_create();
1155
0
            run_bitset_container_lazy_union(const_CAST_run(c2),
1156
0
                                            const_CAST_bitset(c1),
1157
0
                                            CAST_bitset(result));  // is lazy
1158
0
            *result_type = BITSET_CONTAINER_TYPE;
1159
0
            return result;
1160
1161
0
        case CONTAINER_PAIR(RUN, BITSET):
1162
0
            if (run_container_is_full(const_CAST_run(c1))) {
1163
0
                result = run_container_create();
1164
0
                *result_type = RUN_CONTAINER_TYPE;
1165
0
                run_container_copy(const_CAST_run(c1), CAST_run(result));
1166
0
                return result;
1167
0
            }
1168
0
            result = bitset_container_create();
1169
0
            run_bitset_container_lazy_union(const_CAST_run(c1),
1170
0
                                            const_CAST_bitset(c2),
1171
0
                                            CAST_bitset(result));  // is lazy
1172
0
            *result_type = BITSET_CONTAINER_TYPE;
1173
0
            return result;
1174
1175
0
        case CONTAINER_PAIR(ARRAY, RUN):
1176
0
            result = run_container_create();
1177
0
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1178
0
                                      CAST_run(result));
1179
0
            *result_type = RUN_CONTAINER_TYPE;
1180
            // next line skipped since we are lazy
1181
            // result = convert_run_to_efficient_container(result, result_type);
1182
0
            return result;
1183
1184
0
        case CONTAINER_PAIR(RUN, ARRAY):
1185
0
            result = run_container_create();
1186
0
            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
1187
0
                                      CAST_run(result));  // TODO make lazy
1188
0
            *result_type = RUN_CONTAINER_TYPE;
1189
            // next line skipped since we are lazy
1190
            // result = convert_run_to_efficient_container(result, result_type);
1191
0
            return result;
1192
1193
0
        default:
1194
0
            assert(false);
1195
0
            roaring_unreachable;
1196
0
            return NULL;  // unreached
1197
0
    }
1198
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_lazy_or(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
Unexecuted instantiation: roaring.c:container_lazy_or
Unexecuted instantiation: roaring_array.c:container_lazy_or
Unexecuted instantiation: containers.c:container_lazy_or
Unexecuted instantiation: convert.c:container_lazy_or
Unexecuted instantiation: mixed_negation.c:container_lazy_or
Unexecuted instantiation: mixed_xor.c:container_lazy_or
Unexecuted instantiation: mixed_andnot.c:container_lazy_or
Unexecuted instantiation: roaring64.c:container_lazy_or
1199
1200
/**
1201
 * Compute the union between two containers, with result in the first container.
1202
 * If the returned pointer is identical to c1, then the container has been
1203
 * modified.
1204
 * If the returned pointer is different from c1, then a new container has been
1205
 * created and the caller is responsible for freeing it.
1206
 * The type of the first container may change. Returns the modified
1207
 * (and possibly new) container
1208
 */
1209
static inline container_t *container_ior(container_t *c1, uint8_t type1,
1210
                                         const container_t *c2, uint8_t type2,
1211
5.36k
                                         uint8_t *result_type) {
1212
5.36k
    c1 = get_writable_copy_if_shared(c1, &type1);
1213
5.36k
    c2 = container_unwrap_shared(c2, &type2);
1214
5.36k
    container_t *result = NULL;
1215
5.36k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1216
0
        case CONTAINER_PAIR(BITSET, BITSET):
1217
0
            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
1218
0
                                CAST_bitset(c1));
1219
0
#ifdef OR_BITSET_CONVERSION_TO_FULL
1220
0
            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
1221
0
                result = run_container_create_range(0, (1 << 16));
1222
0
                *result_type = RUN_CONTAINER_TYPE;
1223
0
                return result;
1224
0
            }
1225
0
#endif
1226
0
            *result_type = BITSET_CONTAINER_TYPE;
1227
0
            return c1;
1228
1229
2.14k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1230
2.14k
            *result_type = array_array_container_inplace_union(
1231
2.14k
                               CAST_array(c1), const_CAST_array(c2), &result)
1232
2.14k
                               ? BITSET_CONTAINER_TYPE
1233
2.14k
                               : ARRAY_CONTAINER_TYPE;
1234
2.14k
            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
1235
0
                return c1;  // the computation was done in-place!
1236
0
            }
1237
2.14k
            return result;
1238
1239
1.43k
        case CONTAINER_PAIR(RUN, RUN):
1240
1.43k
            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
1241
1.43k
            return convert_run_to_efficient_container(CAST_run(c1),
1242
1.43k
                                                      result_type);
1243
1244
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1245
0
            array_bitset_container_union(
1246
0
                const_CAST_array(c2), const_CAST_bitset(c1), CAST_bitset(c1));
1247
0
            *result_type = BITSET_CONTAINER_TYPE;  // never array
1248
0
            return c1;
1249
1250
573
        case CONTAINER_PAIR(ARRAY, BITSET):
1251
            // c1 is an array, so no in-place possible
1252
573
            result = bitset_container_create();
1253
573
            *result_type = BITSET_CONTAINER_TYPE;
1254
573
            array_bitset_container_union(const_CAST_array(c1),
1255
573
                                         const_CAST_bitset(c2),
1256
573
                                         CAST_bitset(result));
1257
573
            return result;
1258
1259
0
        case CONTAINER_PAIR(BITSET, RUN):
1260
0
            if (run_container_is_full(const_CAST_run(c2))) {
1261
0
                result = run_container_create();
1262
0
                *result_type = RUN_CONTAINER_TYPE;
1263
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1264
0
                return result;
1265
0
            }
1266
0
            run_bitset_container_union(const_CAST_run(c2),
1267
0
                                       const_CAST_bitset(c1),
1268
0
                                       CAST_bitset(c1));  // allowed
1269
0
            *result_type = BITSET_CONTAINER_TYPE;
1270
0
            return c1;
1271
1272
443
        case CONTAINER_PAIR(RUN, BITSET):
1273
443
            if (run_container_is_full(const_CAST_run(c1))) {
1274
0
                *result_type = RUN_CONTAINER_TYPE;
1275
0
                return c1;
1276
0
            }
1277
443
            result = bitset_container_create();
1278
443
            run_bitset_container_union(
1279
443
                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
1280
443
            *result_type = BITSET_CONTAINER_TYPE;
1281
443
            return result;
1282
1283
575
        case CONTAINER_PAIR(ARRAY, RUN):
1284
575
            result = run_container_create();
1285
575
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1286
575
                                      CAST_run(result));
1287
575
            result = convert_run_to_efficient_container_and_free(
1288
575
                CAST_run(result), result_type);
1289
575
            return result;
1290
1291
195
        case CONTAINER_PAIR(RUN, ARRAY):
1292
195
            array_run_container_inplace_union(const_CAST_array(c2),
1293
195
                                              CAST_run(c1));
1294
195
            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
1295
195
            return c1;
1296
1297
0
        default:
1298
0
            assert(false);
1299
0
            roaring_unreachable;
1300
0
            return NULL;
1301
5.36k
    }
1302
5.36k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_ior(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_ior
Line
Count
Source
1211
5.36k
                                         uint8_t *result_type) {
1212
5.36k
    c1 = get_writable_copy_if_shared(c1, &type1);
1213
5.36k
    c2 = container_unwrap_shared(c2, &type2);
1214
5.36k
    container_t *result = NULL;
1215
5.36k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1216
0
        case CONTAINER_PAIR(BITSET, BITSET):
1217
0
            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
1218
0
                                CAST_bitset(c1));
1219
0
#ifdef OR_BITSET_CONVERSION_TO_FULL
1220
0
            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
1221
0
                result = run_container_create_range(0, (1 << 16));
1222
0
                *result_type = RUN_CONTAINER_TYPE;
1223
0
                return result;
1224
0
            }
1225
0
#endif
1226
0
            *result_type = BITSET_CONTAINER_TYPE;
1227
0
            return c1;
1228
1229
2.14k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1230
2.14k
            *result_type = array_array_container_inplace_union(
1231
2.14k
                               CAST_array(c1), const_CAST_array(c2), &result)
1232
2.14k
                               ? BITSET_CONTAINER_TYPE
1233
2.14k
                               : ARRAY_CONTAINER_TYPE;
1234
2.14k
            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
1235
0
                return c1;  // the computation was done in-place!
1236
0
            }
1237
2.14k
            return result;
1238
1239
1.43k
        case CONTAINER_PAIR(RUN, RUN):
1240
1.43k
            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
1241
1.43k
            return convert_run_to_efficient_container(CAST_run(c1),
1242
1.43k
                                                      result_type);
1243
1244
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1245
0
            array_bitset_container_union(
1246
0
                const_CAST_array(c2), const_CAST_bitset(c1), CAST_bitset(c1));
1247
0
            *result_type = BITSET_CONTAINER_TYPE;  // never array
1248
0
            return c1;
1249
1250
573
        case CONTAINER_PAIR(ARRAY, BITSET):
1251
            // c1 is an array, so no in-place possible
1252
573
            result = bitset_container_create();
1253
573
            *result_type = BITSET_CONTAINER_TYPE;
1254
573
            array_bitset_container_union(const_CAST_array(c1),
1255
573
                                         const_CAST_bitset(c2),
1256
573
                                         CAST_bitset(result));
1257
573
            return result;
1258
1259
0
        case CONTAINER_PAIR(BITSET, RUN):
1260
0
            if (run_container_is_full(const_CAST_run(c2))) {
1261
0
                result = run_container_create();
1262
0
                *result_type = RUN_CONTAINER_TYPE;
1263
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1264
0
                return result;
1265
0
            }
1266
0
            run_bitset_container_union(const_CAST_run(c2),
1267
0
                                       const_CAST_bitset(c1),
1268
0
                                       CAST_bitset(c1));  // allowed
1269
0
            *result_type = BITSET_CONTAINER_TYPE;
1270
0
            return c1;
1271
1272
443
        case CONTAINER_PAIR(RUN, BITSET):
1273
443
            if (run_container_is_full(const_CAST_run(c1))) {
1274
0
                *result_type = RUN_CONTAINER_TYPE;
1275
0
                return c1;
1276
0
            }
1277
443
            result = bitset_container_create();
1278
443
            run_bitset_container_union(
1279
443
                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
1280
443
            *result_type = BITSET_CONTAINER_TYPE;
1281
443
            return result;
1282
1283
575
        case CONTAINER_PAIR(ARRAY, RUN):
1284
575
            result = run_container_create();
1285
575
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1286
575
                                      CAST_run(result));
1287
575
            result = convert_run_to_efficient_container_and_free(
1288
575
                CAST_run(result), result_type);
1289
575
            return result;
1290
1291
195
        case CONTAINER_PAIR(RUN, ARRAY):
1292
195
            array_run_container_inplace_union(const_CAST_array(c2),
1293
195
                                              CAST_run(c1));
1294
195
            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
1295
195
            return c1;
1296
1297
0
        default:
1298
0
            assert(false);
1299
0
            roaring_unreachable;
1300
0
            return NULL;
1301
5.36k
    }
1302
5.36k
}
Unexecuted instantiation: roaring_array.c:container_ior
Unexecuted instantiation: containers.c:container_ior
Unexecuted instantiation: convert.c:container_ior
Unexecuted instantiation: mixed_negation.c:container_ior
Unexecuted instantiation: mixed_xor.c:container_ior
Unexecuted instantiation: mixed_andnot.c:container_ior
Unexecuted instantiation: roaring64.c:container_ior
1303
1304
/**
1305
 * Compute the union between two containers, with result in the first container.
1306
 * If the returned pointer is identical to c1, then the container has been
1307
 * modified.
1308
 * If the returned pointer is different from c1, then a new container has been
1309
 * created and the caller is responsible for freeing it.
1310
 * The type of the first container may change. Returns the modified
1311
 * (and possibly new) container
1312
 *
1313
 * This lazy version delays some operations such as the maintenance of the
1314
 * cardinality. It requires repair later on the generated containers.
1315
 */
1316
static inline container_t *container_lazy_ior(container_t *c1, uint8_t type1,
1317
                                              const container_t *c2,
1318
                                              uint8_t type2,
1319
0
                                              uint8_t *result_type) {
1320
0
    assert(type1 != SHARED_CONTAINER_TYPE);
1321
    // c1 = get_writable_copy_if_shared(c1,&type1);
1322
0
    c2 = container_unwrap_shared(c2, &type2);
1323
0
    container_t *result = NULL;
1324
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1325
0
        case CONTAINER_PAIR(BITSET, BITSET):
1326
0
#ifdef LAZY_OR_BITSET_CONVERSION_TO_FULL
1327
            // if we have two bitsets, we might as well compute the cardinality
1328
0
            bitset_container_or(const_CAST_bitset(c1), const_CAST_bitset(c2),
1329
0
                                CAST_bitset(c1));
1330
            // it is possible that two bitsets can lead to a full container
1331
0
            if (CAST_bitset(c1)->cardinality == (1 << 16)) {  // we convert
1332
0
                result = run_container_create_range(0, (1 << 16));
1333
0
                *result_type = RUN_CONTAINER_TYPE;
1334
0
                return result;
1335
0
            }
1336
#else
1337
            bitset_container_or_nocard(const_CAST_bitset(c1),
1338
                                       const_CAST_bitset(c2), CAST_bitset(c1));
1339
1340
#endif
1341
0
            *result_type = BITSET_CONTAINER_TYPE;
1342
0
            return c1;
1343
1344
0
        case CONTAINER_PAIR(ARRAY, ARRAY):
1345
0
            *result_type = array_array_container_lazy_inplace_union(
1346
0
                               CAST_array(c1), const_CAST_array(c2), &result)
1347
0
                               ? BITSET_CONTAINER_TYPE
1348
0
                               : ARRAY_CONTAINER_TYPE;
1349
0
            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
1350
0
                return c1;  // the computation was done in-place!
1351
0
            }
1352
0
            return result;
1353
1354
0
        case CONTAINER_PAIR(RUN, RUN):
1355
0
            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
1356
0
            *result_type = RUN_CONTAINER_TYPE;
1357
0
            return convert_run_to_efficient_container(CAST_run(c1),
1358
0
                                                      result_type);
1359
1360
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1361
0
            array_bitset_container_lazy_union(const_CAST_array(c2),
1362
0
                                              const_CAST_bitset(c1),
1363
0
                                              CAST_bitset(c1));  // is lazy
1364
0
            *result_type = BITSET_CONTAINER_TYPE;                // never array
1365
0
            return c1;
1366
1367
0
        case CONTAINER_PAIR(ARRAY, BITSET):
1368
            // c1 is an array, so no in-place possible
1369
0
            result = bitset_container_create();
1370
0
            *result_type = BITSET_CONTAINER_TYPE;
1371
0
            array_bitset_container_lazy_union(const_CAST_array(c1),
1372
0
                                              const_CAST_bitset(c2),
1373
0
                                              CAST_bitset(result));  // is lazy
1374
0
            return result;
1375
1376
0
        case CONTAINER_PAIR(BITSET, RUN):
1377
0
            if (run_container_is_full(const_CAST_run(c2))) {
1378
0
                result = run_container_create();
1379
0
                *result_type = RUN_CONTAINER_TYPE;
1380
0
                run_container_copy(const_CAST_run(c2), CAST_run(result));
1381
0
                return result;
1382
0
            }
1383
0
            run_bitset_container_lazy_union(
1384
0
                const_CAST_run(c2), const_CAST_bitset(c1),
1385
0
                CAST_bitset(c1));  // allowed //  lazy
1386
0
            *result_type = BITSET_CONTAINER_TYPE;
1387
0
            return c1;
1388
1389
0
        case CONTAINER_PAIR(RUN, BITSET):
1390
0
            if (run_container_is_full(const_CAST_run(c1))) {
1391
0
                *result_type = RUN_CONTAINER_TYPE;
1392
0
                return c1;
1393
0
            }
1394
0
            result = bitset_container_create();
1395
0
            run_bitset_container_lazy_union(const_CAST_run(c1),
1396
0
                                            const_CAST_bitset(c2),
1397
0
                                            CAST_bitset(result));  //  lazy
1398
0
            *result_type = BITSET_CONTAINER_TYPE;
1399
0
            return result;
1400
1401
0
        case CONTAINER_PAIR(ARRAY, RUN):
1402
0
            result = run_container_create();
1403
0
            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
1404
0
                                      CAST_run(result));
1405
0
            *result_type = RUN_CONTAINER_TYPE;
1406
            // next line skipped since we are lazy
1407
            // result = convert_run_to_efficient_container_and_free(result,
1408
            // result_type);
1409
0
            return result;
1410
1411
0
        case CONTAINER_PAIR(RUN, ARRAY):
1412
0
            array_run_container_inplace_union(const_CAST_array(c2),
1413
0
                                              CAST_run(c1));
1414
0
            *result_type = RUN_CONTAINER_TYPE;
1415
            // next line skipped since we are lazy
1416
            // result = convert_run_to_efficient_container_and_free(result,
1417
            // result_type);
1418
0
            return c1;
1419
1420
0
        default:
1421
0
            assert(false);
1422
0
            roaring_unreachable;
1423
0
            return NULL;
1424
0
    }
1425
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_lazy_ior(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
Unexecuted instantiation: roaring.c:container_lazy_ior
Unexecuted instantiation: roaring_array.c:container_lazy_ior
Unexecuted instantiation: containers.c:container_lazy_ior
Unexecuted instantiation: convert.c:container_lazy_ior
Unexecuted instantiation: mixed_negation.c:container_lazy_ior
Unexecuted instantiation: mixed_xor.c:container_lazy_ior
Unexecuted instantiation: mixed_andnot.c:container_lazy_ior
Unexecuted instantiation: roaring64.c:container_lazy_ior
1426
1427
/**
1428
 * Compute symmetric difference (xor) between two containers, generate a new
1429
 * container (having type result_type), requires a typecode. This allocates new
1430
 * memory, caller is responsible for deallocation.
1431
 */
1432
static inline container_t *container_xor(const container_t *c1, uint8_t type1,
1433
                                         const container_t *c2, uint8_t type2,
1434
5.24k
                                         uint8_t *result_type) {
1435
5.24k
    c1 = container_unwrap_shared(c1, &type1);
1436
5.24k
    c2 = container_unwrap_shared(c2, &type2);
1437
5.24k
    container_t *result = NULL;
1438
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1439
0
        case CONTAINER_PAIR(BITSET, BITSET):
1440
0
            *result_type =
1441
0
                bitset_bitset_container_xor(const_CAST_bitset(c1),
1442
0
                                            const_CAST_bitset(c2), &result)
1443
0
                    ? BITSET_CONTAINER_TYPE
1444
0
                    : ARRAY_CONTAINER_TYPE;
1445
0
            return result;
1446
1447
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1448
1.99k
            *result_type =
1449
1.99k
                array_array_container_xor(const_CAST_array(c1),
1450
1.99k
                                          const_CAST_array(c2), &result)
1451
1.99k
                    ? BITSET_CONTAINER_TYPE
1452
1.99k
                    : ARRAY_CONTAINER_TYPE;
1453
1.99k
            return result;
1454
1455
576
        case CONTAINER_PAIR(RUN, RUN):
1456
576
            *result_type = (uint8_t)run_run_container_xor(
1457
576
                const_CAST_run(c1), const_CAST_run(c2), &result);
1458
576
            return result;
1459
1460
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1461
0
            *result_type =
1462
0
                array_bitset_container_xor(const_CAST_array(c2),
1463
0
                                           const_CAST_bitset(c1), &result)
1464
0
                    ? BITSET_CONTAINER_TYPE
1465
0
                    : ARRAY_CONTAINER_TYPE;
1466
0
            return result;
1467
1468
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1469
513
            *result_type =
1470
513
                array_bitset_container_xor(const_CAST_array(c1),
1471
513
                                           const_CAST_bitset(c2), &result)
1472
513
                    ? BITSET_CONTAINER_TYPE
1473
513
                    : ARRAY_CONTAINER_TYPE;
1474
513
            return result;
1475
1476
0
        case CONTAINER_PAIR(BITSET, RUN):
1477
0
            *result_type =
1478
0
                run_bitset_container_xor(const_CAST_run(c2),
1479
0
                                         const_CAST_bitset(c1), &result)
1480
0
                    ? BITSET_CONTAINER_TYPE
1481
0
                    : ARRAY_CONTAINER_TYPE;
1482
0
            return result;
1483
1484
443
        case CONTAINER_PAIR(RUN, BITSET):
1485
443
            *result_type =
1486
443
                run_bitset_container_xor(const_CAST_run(c1),
1487
443
                                         const_CAST_bitset(c2), &result)
1488
443
                    ? BITSET_CONTAINER_TYPE
1489
443
                    : ARRAY_CONTAINER_TYPE;
1490
443
            return result;
1491
1492
693
        case CONTAINER_PAIR(ARRAY, RUN):
1493
693
            *result_type = (uint8_t)array_run_container_xor(
1494
693
                const_CAST_array(c1), const_CAST_run(c2), &result);
1495
693
            return result;
1496
1497
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1498
1.02k
            *result_type = (uint8_t)array_run_container_xor(
1499
1.02k
                const_CAST_array(c2), const_CAST_run(c1), &result);
1500
1.02k
            return result;
1501
1502
0
        default:
1503
0
            assert(false);
1504
0
            roaring_unreachable;
1505
0
            return NULL;  // unreached
1506
5.24k
    }
1507
5.24k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_xor(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_xor
Line
Count
Source
1434
5.24k
                                         uint8_t *result_type) {
1435
5.24k
    c1 = container_unwrap_shared(c1, &type1);
1436
5.24k
    c2 = container_unwrap_shared(c2, &type2);
1437
5.24k
    container_t *result = NULL;
1438
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1439
0
        case CONTAINER_PAIR(BITSET, BITSET):
1440
0
            *result_type =
1441
0
                bitset_bitset_container_xor(const_CAST_bitset(c1),
1442
0
                                            const_CAST_bitset(c2), &result)
1443
0
                    ? BITSET_CONTAINER_TYPE
1444
0
                    : ARRAY_CONTAINER_TYPE;
1445
0
            return result;
1446
1447
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1448
1.99k
            *result_type =
1449
1.99k
                array_array_container_xor(const_CAST_array(c1),
1450
1.99k
                                          const_CAST_array(c2), &result)
1451
1.99k
                    ? BITSET_CONTAINER_TYPE
1452
1.99k
                    : ARRAY_CONTAINER_TYPE;
1453
1.99k
            return result;
1454
1455
576
        case CONTAINER_PAIR(RUN, RUN):
1456
576
            *result_type = (uint8_t)run_run_container_xor(
1457
576
                const_CAST_run(c1), const_CAST_run(c2), &result);
1458
576
            return result;
1459
1460
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1461
0
            *result_type =
1462
0
                array_bitset_container_xor(const_CAST_array(c2),
1463
0
                                           const_CAST_bitset(c1), &result)
1464
0
                    ? BITSET_CONTAINER_TYPE
1465
0
                    : ARRAY_CONTAINER_TYPE;
1466
0
            return result;
1467
1468
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1469
513
            *result_type =
1470
513
                array_bitset_container_xor(const_CAST_array(c1),
1471
513
                                           const_CAST_bitset(c2), &result)
1472
513
                    ? BITSET_CONTAINER_TYPE
1473
513
                    : ARRAY_CONTAINER_TYPE;
1474
513
            return result;
1475
1476
0
        case CONTAINER_PAIR(BITSET, RUN):
1477
0
            *result_type =
1478
0
                run_bitset_container_xor(const_CAST_run(c2),
1479
0
                                         const_CAST_bitset(c1), &result)
1480
0
                    ? BITSET_CONTAINER_TYPE
1481
0
                    : ARRAY_CONTAINER_TYPE;
1482
0
            return result;
1483
1484
443
        case CONTAINER_PAIR(RUN, BITSET):
1485
443
            *result_type =
1486
443
                run_bitset_container_xor(const_CAST_run(c1),
1487
443
                                         const_CAST_bitset(c2), &result)
1488
443
                    ? BITSET_CONTAINER_TYPE
1489
443
                    : ARRAY_CONTAINER_TYPE;
1490
443
            return result;
1491
1492
693
        case CONTAINER_PAIR(ARRAY, RUN):
1493
693
            *result_type = (uint8_t)array_run_container_xor(
1494
693
                const_CAST_array(c1), const_CAST_run(c2), &result);
1495
693
            return result;
1496
1497
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1498
1.02k
            *result_type = (uint8_t)array_run_container_xor(
1499
1.02k
                const_CAST_array(c2), const_CAST_run(c1), &result);
1500
1.02k
            return result;
1501
1502
0
        default:
1503
0
            assert(false);
1504
0
            roaring_unreachable;
1505
0
            return NULL;  // unreached
1506
5.24k
    }
1507
5.24k
}
Unexecuted instantiation: roaring_array.c:container_xor
Unexecuted instantiation: containers.c:container_xor
Unexecuted instantiation: convert.c:container_xor
Unexecuted instantiation: mixed_negation.c:container_xor
Unexecuted instantiation: mixed_xor.c:container_xor
Unexecuted instantiation: mixed_andnot.c:container_xor
Unexecuted instantiation: roaring64.c:container_xor
1508
1509
/* Applies an offset to the non-empty container 'c'.
1510
 * The results are stored in new containers returned via 'lo' and 'hi', for the
1511
 * low and high halves of the result (where the low half matches the original
1512
 * key and the high one corresponds to values for the following key). Either one
1513
 * of 'lo' and 'hi' are allowed to be 'NULL', but not both. Whenever one of them
1514
 * is not 'NULL', it should point to a 'NULL' container. Whenever one of them is
1515
 * 'NULL' the shifted elements for that part will not be computed. If either of
1516
 * the resulting containers turns out to be empty, the pointed container will
1517
 * remain 'NULL'.
1518
 */
1519
static inline void container_add_offset(const container_t *c, uint8_t type,
1520
                                        container_t **lo, container_t **hi,
1521
0
                                        uint16_t offset) {
1522
0
    assert(offset != 0);
1523
0
    assert(container_nonzero_cardinality(c, type));
1524
0
    assert(lo != NULL || hi != NULL);
1525
0
    assert(lo == NULL || *lo == NULL);
1526
0
    assert(hi == NULL || *hi == NULL);
1527
1528
0
    switch (type) {
1529
0
        case BITSET_CONTAINER_TYPE:
1530
0
            bitset_container_offset(const_CAST_bitset(c), lo, hi, offset);
1531
0
            break;
1532
0
        case ARRAY_CONTAINER_TYPE:
1533
0
            array_container_offset(const_CAST_array(c), lo, hi, offset);
1534
0
            break;
1535
0
        case RUN_CONTAINER_TYPE:
1536
0
            run_container_offset(const_CAST_run(c), lo, hi, offset);
1537
0
            break;
1538
0
        default:
1539
0
            assert(false);
1540
0
            roaring_unreachable;
1541
0
            break;
1542
0
    }
1543
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_add_offset(roaring::api::container_s const*, unsigned char, roaring::api::container_s**, roaring::api::container_s**, unsigned short)
Unexecuted instantiation: roaring.c:container_add_offset
Unexecuted instantiation: roaring_array.c:container_add_offset
Unexecuted instantiation: containers.c:container_add_offset
Unexecuted instantiation: convert.c:container_add_offset
Unexecuted instantiation: mixed_negation.c:container_add_offset
Unexecuted instantiation: mixed_xor.c:container_add_offset
Unexecuted instantiation: mixed_andnot.c:container_add_offset
Unexecuted instantiation: roaring64.c:container_add_offset
1544
1545
/**
1546
 * Compute xor between two containers, generate a new container (having type
1547
 * result_type), requires a typecode. This allocates new memory, caller
1548
 * is responsible for deallocation.
1549
 *
1550
 * This lazy version delays some operations such as the maintenance of the
1551
 * cardinality. It requires repair later on the generated containers.
1552
 */
1553
static inline container_t *container_lazy_xor(const container_t *c1,
1554
                                              uint8_t type1,
1555
                                              const container_t *c2,
1556
                                              uint8_t type2,
1557
0
                                              uint8_t *result_type) {
1558
0
    c1 = container_unwrap_shared(c1, &type1);
1559
0
    c2 = container_unwrap_shared(c2, &type2);
1560
0
    container_t *result = NULL;
1561
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1562
0
        case CONTAINER_PAIR(BITSET, BITSET):
1563
0
            result = bitset_container_create();
1564
0
            bitset_container_xor_nocard(const_CAST_bitset(c1),
1565
0
                                        const_CAST_bitset(c2),
1566
0
                                        CAST_bitset(result));  // is lazy
1567
0
            *result_type = BITSET_CONTAINER_TYPE;
1568
0
            return result;
1569
1570
0
        case CONTAINER_PAIR(ARRAY, ARRAY):
1571
0
            *result_type =
1572
0
                array_array_container_lazy_xor(const_CAST_array(c1),
1573
0
                                               const_CAST_array(c2), &result)
1574
0
                    ? BITSET_CONTAINER_TYPE
1575
0
                    : ARRAY_CONTAINER_TYPE;
1576
0
            return result;
1577
1578
0
        case CONTAINER_PAIR(RUN, RUN):
1579
            // nothing special done yet.
1580
0
            *result_type = (uint8_t)run_run_container_xor(
1581
0
                const_CAST_run(c1), const_CAST_run(c2), &result);
1582
0
            return result;
1583
1584
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1585
0
            result = bitset_container_create();
1586
0
            *result_type = BITSET_CONTAINER_TYPE;
1587
0
            array_bitset_container_lazy_xor(const_CAST_array(c2),
1588
0
                                            const_CAST_bitset(c1),
1589
0
                                            CAST_bitset(result));
1590
0
            return result;
1591
1592
0
        case CONTAINER_PAIR(ARRAY, BITSET):
1593
0
            result = bitset_container_create();
1594
0
            *result_type = BITSET_CONTAINER_TYPE;
1595
0
            array_bitset_container_lazy_xor(const_CAST_array(c1),
1596
0
                                            const_CAST_bitset(c2),
1597
0
                                            CAST_bitset(result));
1598
0
            return result;
1599
1600
0
        case CONTAINER_PAIR(BITSET, RUN):
1601
0
            result = bitset_container_create();
1602
0
            run_bitset_container_lazy_xor(
1603
0
                const_CAST_run(c2), const_CAST_bitset(c1), CAST_bitset(result));
1604
0
            *result_type = BITSET_CONTAINER_TYPE;
1605
0
            return result;
1606
1607
0
        case CONTAINER_PAIR(RUN, BITSET):
1608
0
            result = bitset_container_create();
1609
0
            run_bitset_container_lazy_xor(
1610
0
                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
1611
0
            *result_type = BITSET_CONTAINER_TYPE;
1612
0
            return result;
1613
1614
0
        case CONTAINER_PAIR(ARRAY, RUN):
1615
0
            result = run_container_create();
1616
0
            array_run_container_lazy_xor(const_CAST_array(c1),
1617
0
                                         const_CAST_run(c2), CAST_run(result));
1618
0
            *result_type = RUN_CONTAINER_TYPE;
1619
            // next line skipped since we are lazy
1620
            // result = convert_run_to_efficient_container(result, result_type);
1621
0
            return result;
1622
1623
0
        case CONTAINER_PAIR(RUN, ARRAY):
1624
0
            result = run_container_create();
1625
0
            array_run_container_lazy_xor(const_CAST_array(c2),
1626
0
                                         const_CAST_run(c1), CAST_run(result));
1627
0
            *result_type = RUN_CONTAINER_TYPE;
1628
            // next line skipped since we are lazy
1629
            // result = convert_run_to_efficient_container(result, result_type);
1630
0
            return result;
1631
1632
0
        default:
1633
0
            assert(false);
1634
0
            roaring_unreachable;
1635
0
            return NULL;  // unreached
1636
0
    }
1637
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_lazy_xor(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
Unexecuted instantiation: roaring.c:container_lazy_xor
Unexecuted instantiation: roaring_array.c:container_lazy_xor
Unexecuted instantiation: containers.c:container_lazy_xor
Unexecuted instantiation: convert.c:container_lazy_xor
Unexecuted instantiation: mixed_negation.c:container_lazy_xor
Unexecuted instantiation: mixed_xor.c:container_lazy_xor
Unexecuted instantiation: mixed_andnot.c:container_lazy_xor
Unexecuted instantiation: roaring64.c:container_lazy_xor
1638
1639
/**
1640
 * Compute the xor between two containers, with result in the first container.
1641
 * If the returned pointer is identical to c1, then the container has been
1642
 * modified.
1643
 * If the returned pointer is different from c1, then a new container has been
1644
 * created. The original container is freed by container_ixor.
1645
 * The type of the first container may change. Returns the modified (and
1646
 * possibly new) container.
1647
 */
1648
static inline container_t *container_ixor(container_t *c1, uint8_t type1,
1649
                                          const container_t *c2, uint8_t type2,
1650
70.7k
                                          uint8_t *result_type) {
1651
70.7k
    c1 = get_writable_copy_if_shared(c1, &type1);
1652
70.7k
    c2 = container_unwrap_shared(c2, &type2);
1653
70.7k
    container_t *result = NULL;
1654
70.7k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1655
1.27k
        case CONTAINER_PAIR(BITSET, BITSET):
1656
1.27k
            *result_type = bitset_bitset_container_ixor(
1657
1.27k
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
1658
1.27k
                               ? BITSET_CONTAINER_TYPE
1659
1.27k
                               : ARRAY_CONTAINER_TYPE;
1660
1.27k
            return result;
1661
1662
4.35k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1663
4.35k
            *result_type = array_array_container_ixor(
1664
4.35k
                               CAST_array(c1), const_CAST_array(c2), &result)
1665
4.35k
                               ? BITSET_CONTAINER_TYPE
1666
4.35k
                               : ARRAY_CONTAINER_TYPE;
1667
4.35k
            return result;
1668
1669
64.6k
        case CONTAINER_PAIR(RUN, RUN):
1670
64.6k
            *result_type = (uint8_t)run_run_container_ixor(
1671
64.6k
                CAST_run(c1), const_CAST_run(c2), &result);
1672
64.6k
            return result;
1673
1674
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1675
0
            *result_type = bitset_array_container_ixor(
1676
0
                               CAST_bitset(c1), const_CAST_array(c2), &result)
1677
0
                               ? BITSET_CONTAINER_TYPE
1678
0
                               : ARRAY_CONTAINER_TYPE;
1679
0
            return result;
1680
1681
64
        case CONTAINER_PAIR(ARRAY, BITSET):
1682
64
            *result_type = array_bitset_container_ixor(
1683
64
                               CAST_array(c1), const_CAST_bitset(c2), &result)
1684
64
                               ? BITSET_CONTAINER_TYPE
1685
64
                               : ARRAY_CONTAINER_TYPE;
1686
64
            return result;
1687
1688
68
        case CONTAINER_PAIR(BITSET, RUN):
1689
68
            *result_type = bitset_run_container_ixor(
1690
68
                               CAST_bitset(c1), const_CAST_run(c2), &result)
1691
68
                               ? BITSET_CONTAINER_TYPE
1692
68
                               : ARRAY_CONTAINER_TYPE;
1693
1694
68
            return result;
1695
1696
19
        case CONTAINER_PAIR(RUN, BITSET):
1697
19
            *result_type = run_bitset_container_ixor(
1698
19
                               CAST_run(c1), const_CAST_bitset(c2), &result)
1699
19
                               ? BITSET_CONTAINER_TYPE
1700
19
                               : ARRAY_CONTAINER_TYPE;
1701
19
            return result;
1702
1703
220
        case CONTAINER_PAIR(ARRAY, RUN):
1704
220
            *result_type = (uint8_t)array_run_container_ixor(
1705
220
                CAST_array(c1), const_CAST_run(c2), &result);
1706
220
            return result;
1707
1708
43
        case CONTAINER_PAIR(RUN, ARRAY):
1709
43
            *result_type = (uint8_t)run_array_container_ixor(
1710
43
                CAST_run(c1), const_CAST_array(c2), &result);
1711
43
            return result;
1712
1713
0
        default:
1714
0
            assert(false);
1715
0
            roaring_unreachable;
1716
0
            return NULL;
1717
70.7k
    }
1718
70.7k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_ixor(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_ixor
Line
Count
Source
1650
70.7k
                                          uint8_t *result_type) {
1651
70.7k
    c1 = get_writable_copy_if_shared(c1, &type1);
1652
70.7k
    c2 = container_unwrap_shared(c2, &type2);
1653
70.7k
    container_t *result = NULL;
1654
70.7k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1655
1.27k
        case CONTAINER_PAIR(BITSET, BITSET):
1656
1.27k
            *result_type = bitset_bitset_container_ixor(
1657
1.27k
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
1658
1.27k
                               ? BITSET_CONTAINER_TYPE
1659
1.27k
                               : ARRAY_CONTAINER_TYPE;
1660
1.27k
            return result;
1661
1662
4.35k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1663
4.35k
            *result_type = array_array_container_ixor(
1664
4.35k
                               CAST_array(c1), const_CAST_array(c2), &result)
1665
4.35k
                               ? BITSET_CONTAINER_TYPE
1666
4.35k
                               : ARRAY_CONTAINER_TYPE;
1667
4.35k
            return result;
1668
1669
64.6k
        case CONTAINER_PAIR(RUN, RUN):
1670
64.6k
            *result_type = (uint8_t)run_run_container_ixor(
1671
64.6k
                CAST_run(c1), const_CAST_run(c2), &result);
1672
64.6k
            return result;
1673
1674
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1675
0
            *result_type = bitset_array_container_ixor(
1676
0
                               CAST_bitset(c1), const_CAST_array(c2), &result)
1677
0
                               ? BITSET_CONTAINER_TYPE
1678
0
                               : ARRAY_CONTAINER_TYPE;
1679
0
            return result;
1680
1681
64
        case CONTAINER_PAIR(ARRAY, BITSET):
1682
64
            *result_type = array_bitset_container_ixor(
1683
64
                               CAST_array(c1), const_CAST_bitset(c2), &result)
1684
64
                               ? BITSET_CONTAINER_TYPE
1685
64
                               : ARRAY_CONTAINER_TYPE;
1686
64
            return result;
1687
1688
68
        case CONTAINER_PAIR(BITSET, RUN):
1689
68
            *result_type = bitset_run_container_ixor(
1690
68
                               CAST_bitset(c1), const_CAST_run(c2), &result)
1691
68
                               ? BITSET_CONTAINER_TYPE
1692
68
                               : ARRAY_CONTAINER_TYPE;
1693
1694
68
            return result;
1695
1696
19
        case CONTAINER_PAIR(RUN, BITSET):
1697
19
            *result_type = run_bitset_container_ixor(
1698
19
                               CAST_run(c1), const_CAST_bitset(c2), &result)
1699
19
                               ? BITSET_CONTAINER_TYPE
1700
19
                               : ARRAY_CONTAINER_TYPE;
1701
19
            return result;
1702
1703
220
        case CONTAINER_PAIR(ARRAY, RUN):
1704
220
            *result_type = (uint8_t)array_run_container_ixor(
1705
220
                CAST_array(c1), const_CAST_run(c2), &result);
1706
220
            return result;
1707
1708
43
        case CONTAINER_PAIR(RUN, ARRAY):
1709
43
            *result_type = (uint8_t)run_array_container_ixor(
1710
43
                CAST_run(c1), const_CAST_array(c2), &result);
1711
43
            return result;
1712
1713
0
        default:
1714
0
            assert(false);
1715
0
            roaring_unreachable;
1716
0
            return NULL;
1717
70.7k
    }
1718
70.7k
}
Unexecuted instantiation: roaring_array.c:container_ixor
Unexecuted instantiation: containers.c:container_ixor
Unexecuted instantiation: convert.c:container_ixor
Unexecuted instantiation: mixed_negation.c:container_ixor
Unexecuted instantiation: mixed_xor.c:container_ixor
Unexecuted instantiation: mixed_andnot.c:container_ixor
Unexecuted instantiation: roaring64.c:container_ixor
1719
1720
/**
1721
 * Compute the xor between two containers, with result in the first container.
1722
 * If the returned pointer is identical to c1, then the container has been
1723
 * modified.
1724
 * If the returned pointer is different from c1, then a new container has been
1725
 * created and the caller is responsible for freeing it.
1726
 * The type of the first container may change. Returns the modified
1727
 * (and possibly new) container
1728
 *
1729
 * This lazy version delays some operations such as the maintenance of the
1730
 * cardinality. It requires repair later on the generated containers.
1731
 */
1732
static inline container_t *container_lazy_ixor(container_t *c1, uint8_t type1,
1733
                                               const container_t *c2,
1734
                                               uint8_t type2,
1735
0
                                               uint8_t *result_type) {
1736
0
    assert(type1 != SHARED_CONTAINER_TYPE);
1737
    // c1 = get_writable_copy_if_shared(c1,&type1);
1738
0
    c2 = container_unwrap_shared(c2, &type2);
1739
0
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1740
0
        case CONTAINER_PAIR(BITSET, BITSET):
1741
0
            bitset_container_xor_nocard(CAST_bitset(c1), const_CAST_bitset(c2),
1742
0
                                        CAST_bitset(c1));  // is lazy
1743
0
            *result_type = BITSET_CONTAINER_TYPE;
1744
0
            return c1;
1745
1746
        // TODO: other cases being lazy, esp. when we know inplace not likely
1747
        // could see the corresponding code for union
1748
0
        default:
1749
            // we may have a dirty bitset (without a precomputed cardinality)
1750
            // and calling container_ixor on it might be unsafe.
1751
0
            if (type1 == BITSET_CONTAINER_TYPE) {
1752
0
                bitset_container_t *bc = CAST_bitset(c1);
1753
0
                if (bc->cardinality == BITSET_UNKNOWN_CARDINALITY) {
1754
0
                    bc->cardinality = bitset_container_compute_cardinality(bc);
1755
0
                }
1756
0
            }
1757
0
            return container_ixor(c1, type1, c2, type2, result_type);
1758
0
    }
1759
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_lazy_ixor(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
Unexecuted instantiation: roaring.c:container_lazy_ixor
Unexecuted instantiation: roaring_array.c:container_lazy_ixor
Unexecuted instantiation: containers.c:container_lazy_ixor
Unexecuted instantiation: convert.c:container_lazy_ixor
Unexecuted instantiation: mixed_negation.c:container_lazy_ixor
Unexecuted instantiation: mixed_xor.c:container_lazy_ixor
Unexecuted instantiation: mixed_andnot.c:container_lazy_ixor
Unexecuted instantiation: roaring64.c:container_lazy_ixor
1760
1761
/**
1762
 * Compute difference (andnot) between two containers, generate a new
1763
 * container (having type result_type), requires a typecode. This allocates new
1764
 * memory, caller is responsible for deallocation.
1765
 */
1766
static inline container_t *container_andnot(const container_t *c1,
1767
                                            uint8_t type1,
1768
                                            const container_t *c2,
1769
                                            uint8_t type2,
1770
5.24k
                                            uint8_t *result_type) {
1771
5.24k
    c1 = container_unwrap_shared(c1, &type1);
1772
5.24k
    c2 = container_unwrap_shared(c2, &type2);
1773
5.24k
    container_t *result = NULL;
1774
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1775
0
        case CONTAINER_PAIR(BITSET, BITSET):
1776
0
            *result_type =
1777
0
                bitset_bitset_container_andnot(const_CAST_bitset(c1),
1778
0
                                               const_CAST_bitset(c2), &result)
1779
0
                    ? BITSET_CONTAINER_TYPE
1780
0
                    : ARRAY_CONTAINER_TYPE;
1781
0
            return result;
1782
1783
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1784
1.99k
            result = array_container_create();
1785
1.99k
            array_array_container_andnot(
1786
1.99k
                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
1787
1.99k
            *result_type = ARRAY_CONTAINER_TYPE;
1788
1.99k
            return result;
1789
1790
576
        case CONTAINER_PAIR(RUN, RUN):
1791
576
            if (run_container_is_full(const_CAST_run(c2))) {
1792
9
                result = array_container_create();
1793
9
                *result_type = ARRAY_CONTAINER_TYPE;
1794
9
                return result;
1795
9
            }
1796
567
            *result_type = (uint8_t)run_run_container_andnot(
1797
567
                const_CAST_run(c1), const_CAST_run(c2), &result);
1798
567
            return result;
1799
1800
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1801
0
            *result_type =
1802
0
                bitset_array_container_andnot(const_CAST_bitset(c1),
1803
0
                                              const_CAST_array(c2), &result)
1804
0
                    ? BITSET_CONTAINER_TYPE
1805
0
                    : ARRAY_CONTAINER_TYPE;
1806
0
            return result;
1807
1808
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1809
513
            result = array_container_create();
1810
513
            array_bitset_container_andnot(const_CAST_array(c1),
1811
513
                                          const_CAST_bitset(c2),
1812
513
                                          CAST_array(result));
1813
513
            *result_type = ARRAY_CONTAINER_TYPE;
1814
513
            return result;
1815
1816
0
        case CONTAINER_PAIR(BITSET, RUN):
1817
0
            if (run_container_is_full(const_CAST_run(c2))) {
1818
0
                result = array_container_create();
1819
0
                *result_type = ARRAY_CONTAINER_TYPE;
1820
0
                return result;
1821
0
            }
1822
0
            *result_type =
1823
0
                bitset_run_container_andnot(const_CAST_bitset(c1),
1824
0
                                            const_CAST_run(c2), &result)
1825
0
                    ? BITSET_CONTAINER_TYPE
1826
0
                    : ARRAY_CONTAINER_TYPE;
1827
0
            return result;
1828
1829
443
        case CONTAINER_PAIR(RUN, BITSET):
1830
443
            *result_type =
1831
443
                run_bitset_container_andnot(const_CAST_run(c1),
1832
443
                                            const_CAST_bitset(c2), &result)
1833
443
                    ? BITSET_CONTAINER_TYPE
1834
443
                    : ARRAY_CONTAINER_TYPE;
1835
443
            return result;
1836
1837
693
        case CONTAINER_PAIR(ARRAY, RUN):
1838
693
            if (run_container_is_full(const_CAST_run(c2))) {
1839
32
                result = array_container_create();
1840
32
                *result_type = ARRAY_CONTAINER_TYPE;
1841
32
                return result;
1842
32
            }
1843
661
            result = array_container_create();
1844
661
            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
1845
661
                                       CAST_array(result));
1846
661
            *result_type = ARRAY_CONTAINER_TYPE;
1847
661
            return result;
1848
1849
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1850
1.02k
            *result_type = (uint8_t)run_array_container_andnot(
1851
1.02k
                const_CAST_run(c1), const_CAST_array(c2), &result);
1852
1.02k
            return result;
1853
1854
0
        default:
1855
0
            assert(false);
1856
0
            roaring_unreachable;
1857
0
            return NULL;  // unreached
1858
5.24k
    }
1859
5.24k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_andnot(roaring::api::container_s const*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_andnot
Line
Count
Source
1770
5.24k
                                            uint8_t *result_type) {
1771
5.24k
    c1 = container_unwrap_shared(c1, &type1);
1772
5.24k
    c2 = container_unwrap_shared(c2, &type2);
1773
5.24k
    container_t *result = NULL;
1774
5.24k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1775
0
        case CONTAINER_PAIR(BITSET, BITSET):
1776
0
            *result_type =
1777
0
                bitset_bitset_container_andnot(const_CAST_bitset(c1),
1778
0
                                               const_CAST_bitset(c2), &result)
1779
0
                    ? BITSET_CONTAINER_TYPE
1780
0
                    : ARRAY_CONTAINER_TYPE;
1781
0
            return result;
1782
1783
1.99k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1784
1.99k
            result = array_container_create();
1785
1.99k
            array_array_container_andnot(
1786
1.99k
                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
1787
1.99k
            *result_type = ARRAY_CONTAINER_TYPE;
1788
1.99k
            return result;
1789
1790
576
        case CONTAINER_PAIR(RUN, RUN):
1791
576
            if (run_container_is_full(const_CAST_run(c2))) {
1792
9
                result = array_container_create();
1793
9
                *result_type = ARRAY_CONTAINER_TYPE;
1794
9
                return result;
1795
9
            }
1796
567
            *result_type = (uint8_t)run_run_container_andnot(
1797
567
                const_CAST_run(c1), const_CAST_run(c2), &result);
1798
567
            return result;
1799
1800
0
        case CONTAINER_PAIR(BITSET, ARRAY):
1801
0
            *result_type =
1802
0
                bitset_array_container_andnot(const_CAST_bitset(c1),
1803
0
                                              const_CAST_array(c2), &result)
1804
0
                    ? BITSET_CONTAINER_TYPE
1805
0
                    : ARRAY_CONTAINER_TYPE;
1806
0
            return result;
1807
1808
513
        case CONTAINER_PAIR(ARRAY, BITSET):
1809
513
            result = array_container_create();
1810
513
            array_bitset_container_andnot(const_CAST_array(c1),
1811
513
                                          const_CAST_bitset(c2),
1812
513
                                          CAST_array(result));
1813
513
            *result_type = ARRAY_CONTAINER_TYPE;
1814
513
            return result;
1815
1816
0
        case CONTAINER_PAIR(BITSET, RUN):
1817
0
            if (run_container_is_full(const_CAST_run(c2))) {
1818
0
                result = array_container_create();
1819
0
                *result_type = ARRAY_CONTAINER_TYPE;
1820
0
                return result;
1821
0
            }
1822
0
            *result_type =
1823
0
                bitset_run_container_andnot(const_CAST_bitset(c1),
1824
0
                                            const_CAST_run(c2), &result)
1825
0
                    ? BITSET_CONTAINER_TYPE
1826
0
                    : ARRAY_CONTAINER_TYPE;
1827
0
            return result;
1828
1829
443
        case CONTAINER_PAIR(RUN, BITSET):
1830
443
            *result_type =
1831
443
                run_bitset_container_andnot(const_CAST_run(c1),
1832
443
                                            const_CAST_bitset(c2), &result)
1833
443
                    ? BITSET_CONTAINER_TYPE
1834
443
                    : ARRAY_CONTAINER_TYPE;
1835
443
            return result;
1836
1837
693
        case CONTAINER_PAIR(ARRAY, RUN):
1838
693
            if (run_container_is_full(const_CAST_run(c2))) {
1839
32
                result = array_container_create();
1840
32
                *result_type = ARRAY_CONTAINER_TYPE;
1841
32
                return result;
1842
32
            }
1843
661
            result = array_container_create();
1844
661
            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
1845
661
                                       CAST_array(result));
1846
661
            *result_type = ARRAY_CONTAINER_TYPE;
1847
661
            return result;
1848
1849
1.02k
        case CONTAINER_PAIR(RUN, ARRAY):
1850
1.02k
            *result_type = (uint8_t)run_array_container_andnot(
1851
1.02k
                const_CAST_run(c1), const_CAST_array(c2), &result);
1852
1.02k
            return result;
1853
1854
0
        default:
1855
0
            assert(false);
1856
0
            roaring_unreachable;
1857
0
            return NULL;  // unreached
1858
5.24k
    }
1859
5.24k
}
Unexecuted instantiation: roaring_array.c:container_andnot
Unexecuted instantiation: containers.c:container_andnot
Unexecuted instantiation: convert.c:container_andnot
Unexecuted instantiation: mixed_negation.c:container_andnot
Unexecuted instantiation: mixed_xor.c:container_andnot
Unexecuted instantiation: mixed_andnot.c:container_andnot
Unexecuted instantiation: roaring64.c:container_andnot
1860
1861
/**
1862
 * Compute the andnot between two containers, with result in the first
1863
 * container.
1864
 * If the returned pointer is identical to c1, then the container has been
1865
 * modified.
1866
 * If the returned pointer is different from c1, then a new container has been
1867
 * created. The original container is freed by container_iandnot.
1868
 * The type of the first container may change. Returns the modified (and
1869
 * possibly new) container.
1870
 */
1871
static inline container_t *container_iandnot(container_t *c1, uint8_t type1,
1872
                                             const container_t *c2,
1873
                                             uint8_t type2,
1874
4.98k
                                             uint8_t *result_type) {
1875
4.98k
    c1 = get_writable_copy_if_shared(c1, &type1);
1876
4.98k
    c2 = container_unwrap_shared(c2, &type2);
1877
4.98k
    container_t *result = NULL;
1878
4.98k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1879
0
        case CONTAINER_PAIR(BITSET, BITSET):
1880
0
            *result_type = bitset_bitset_container_iandnot(
1881
0
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
1882
0
                               ? BITSET_CONTAINER_TYPE
1883
0
                               : ARRAY_CONTAINER_TYPE;
1884
0
            return result;
1885
1886
3.00k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1887
3.00k
            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
1888
3.00k
            *result_type = ARRAY_CONTAINER_TYPE;
1889
3.00k
            return c1;
1890
1891
402
        case CONTAINER_PAIR(RUN, RUN):
1892
402
            *result_type = (uint8_t)run_run_container_iandnot(
1893
402
                CAST_run(c1), const_CAST_run(c2), &result);
1894
402
            return result;
1895
1896
897
        case CONTAINER_PAIR(BITSET, ARRAY):
1897
897
            *result_type = bitset_array_container_iandnot(
1898
897
                               CAST_bitset(c1), const_CAST_array(c2), &result)
1899
897
                               ? BITSET_CONTAINER_TYPE
1900
897
                               : ARRAY_CONTAINER_TYPE;
1901
897
            return result;
1902
1903
0
        case CONTAINER_PAIR(ARRAY, BITSET):
1904
0
            *result_type = ARRAY_CONTAINER_TYPE;
1905
0
            array_bitset_container_iandnot(CAST_array(c1),
1906
0
                                           const_CAST_bitset(c2));
1907
0
            return c1;
1908
1909
0
        case CONTAINER_PAIR(BITSET, RUN):
1910
0
            *result_type = bitset_run_container_iandnot(
1911
0
                               CAST_bitset(c1), const_CAST_run(c2), &result)
1912
0
                               ? BITSET_CONTAINER_TYPE
1913
0
                               : ARRAY_CONTAINER_TYPE;
1914
0
            return result;
1915
1916
0
        case CONTAINER_PAIR(RUN, BITSET):
1917
0
            *result_type = run_bitset_container_iandnot(
1918
0
                               CAST_run(c1), const_CAST_bitset(c2), &result)
1919
0
                               ? BITSET_CONTAINER_TYPE
1920
0
                               : ARRAY_CONTAINER_TYPE;
1921
0
            return result;
1922
1923
33
        case CONTAINER_PAIR(ARRAY, RUN):
1924
33
            *result_type = ARRAY_CONTAINER_TYPE;
1925
33
            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
1926
33
            return c1;
1927
1928
645
        case CONTAINER_PAIR(RUN, ARRAY):
1929
645
            *result_type = (uint8_t)run_array_container_iandnot(
1930
645
                CAST_run(c1), const_CAST_array(c2), &result);
1931
645
            return result;
1932
1933
0
        default:
1934
0
            assert(false);
1935
0
            roaring_unreachable;
1936
0
            return NULL;
1937
4.98k
    }
1938
4.98k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_iandnot(roaring::api::container_s*, unsigned char, roaring::api::container_s const*, unsigned char, unsigned char*)
roaring.c:container_iandnot
Line
Count
Source
1874
4.98k
                                             uint8_t *result_type) {
1875
4.98k
    c1 = get_writable_copy_if_shared(c1, &type1);
1876
4.98k
    c2 = container_unwrap_shared(c2, &type2);
1877
4.98k
    container_t *result = NULL;
1878
4.98k
    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
1879
0
        case CONTAINER_PAIR(BITSET, BITSET):
1880
0
            *result_type = bitset_bitset_container_iandnot(
1881
0
                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
1882
0
                               ? BITSET_CONTAINER_TYPE
1883
0
                               : ARRAY_CONTAINER_TYPE;
1884
0
            return result;
1885
1886
3.00k
        case CONTAINER_PAIR(ARRAY, ARRAY):
1887
3.00k
            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
1888
3.00k
            *result_type = ARRAY_CONTAINER_TYPE;
1889
3.00k
            return c1;
1890
1891
402
        case CONTAINER_PAIR(RUN, RUN):
1892
402
            *result_type = (uint8_t)run_run_container_iandnot(
1893
402
                CAST_run(c1), const_CAST_run(c2), &result);
1894
402
            return result;
1895
1896
897
        case CONTAINER_PAIR(BITSET, ARRAY):
1897
897
            *result_type = bitset_array_container_iandnot(
1898
897
                               CAST_bitset(c1), const_CAST_array(c2), &result)
1899
897
                               ? BITSET_CONTAINER_TYPE
1900
897
                               : ARRAY_CONTAINER_TYPE;
1901
897
            return result;
1902
1903
0
        case CONTAINER_PAIR(ARRAY, BITSET):
1904
0
            *result_type = ARRAY_CONTAINER_TYPE;
1905
0
            array_bitset_container_iandnot(CAST_array(c1),
1906
0
                                           const_CAST_bitset(c2));
1907
0
            return c1;
1908
1909
0
        case CONTAINER_PAIR(BITSET, RUN):
1910
0
            *result_type = bitset_run_container_iandnot(
1911
0
                               CAST_bitset(c1), const_CAST_run(c2), &result)
1912
0
                               ? BITSET_CONTAINER_TYPE
1913
0
                               : ARRAY_CONTAINER_TYPE;
1914
0
            return result;
1915
1916
0
        case CONTAINER_PAIR(RUN, BITSET):
1917
0
            *result_type = run_bitset_container_iandnot(
1918
0
                               CAST_run(c1), const_CAST_bitset(c2), &result)
1919
0
                               ? BITSET_CONTAINER_TYPE
1920
0
                               : ARRAY_CONTAINER_TYPE;
1921
0
            return result;
1922
1923
33
        case CONTAINER_PAIR(ARRAY, RUN):
1924
33
            *result_type = ARRAY_CONTAINER_TYPE;
1925
33
            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
1926
33
            return c1;
1927
1928
645
        case CONTAINER_PAIR(RUN, ARRAY):
1929
645
            *result_type = (uint8_t)run_array_container_iandnot(
1930
645
                CAST_run(c1), const_CAST_array(c2), &result);
1931
645
            return result;
1932
1933
0
        default:
1934
0
            assert(false);
1935
0
            roaring_unreachable;
1936
0
            return NULL;
1937
4.98k
    }
1938
4.98k
}
Unexecuted instantiation: roaring_array.c:container_iandnot
Unexecuted instantiation: containers.c:container_iandnot
Unexecuted instantiation: convert.c:container_iandnot
Unexecuted instantiation: mixed_negation.c:container_iandnot
Unexecuted instantiation: mixed_xor.c:container_iandnot
Unexecuted instantiation: mixed_andnot.c:container_iandnot
Unexecuted instantiation: roaring64.c:container_iandnot
1939
1940
/**
1941
 * Visit all values x of the container once, passing (base+x,ptr)
1942
 * to iterator. You need to specify a container and its type.
1943
 * Returns true if the iteration should continue.
1944
 */
1945
static inline bool container_iterate(const container_t *c, uint8_t type,
1946
                                     uint32_t base, roaring_iterator iterator,
1947
72.0k
                                     void *ptr) {
1948
72.0k
    c = container_unwrap_shared(c, &type);
1949
72.0k
    switch (type) {
1950
1.36k
        case BITSET_CONTAINER_TYPE:
1951
1.36k
            return bitset_container_iterate(const_CAST_bitset(c), base,
1952
1.36k
                                            iterator, ptr);
1953
5.54k
        case ARRAY_CONTAINER_TYPE:
1954
5.54k
            return array_container_iterate(const_CAST_array(c), base, iterator,
1955
5.54k
                                           ptr);
1956
65.1k
        case RUN_CONTAINER_TYPE:
1957
65.1k
            return run_container_iterate(const_CAST_run(c), base, iterator,
1958
65.1k
                                         ptr);
1959
0
        default:
1960
0
            assert(false);
1961
0
            roaring_unreachable;
1962
72.0k
    }
1963
0
    assert(false);
1964
0
    roaring_unreachable;
1965
0
    return false;
1966
72.0k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_iterate(roaring::api::container_s const*, unsigned char, unsigned int, bool (*)(unsigned int, void*), void*)
roaring.c:container_iterate
Line
Count
Source
1947
72.0k
                                     void *ptr) {
1948
72.0k
    c = container_unwrap_shared(c, &type);
1949
72.0k
    switch (type) {
1950
1.36k
        case BITSET_CONTAINER_TYPE:
1951
1.36k
            return bitset_container_iterate(const_CAST_bitset(c), base,
1952
1.36k
                                            iterator, ptr);
1953
5.54k
        case ARRAY_CONTAINER_TYPE:
1954
5.54k
            return array_container_iterate(const_CAST_array(c), base, iterator,
1955
5.54k
                                           ptr);
1956
65.1k
        case RUN_CONTAINER_TYPE:
1957
65.1k
            return run_container_iterate(const_CAST_run(c), base, iterator,
1958
65.1k
                                         ptr);
1959
0
        default:
1960
0
            assert(false);
1961
0
            roaring_unreachable;
1962
72.0k
    }
1963
0
    assert(false);
1964
0
    roaring_unreachable;
1965
0
    return false;
1966
72.0k
}
Unexecuted instantiation: roaring_array.c:container_iterate
Unexecuted instantiation: containers.c:container_iterate
Unexecuted instantiation: convert.c:container_iterate
Unexecuted instantiation: mixed_negation.c:container_iterate
Unexecuted instantiation: mixed_xor.c:container_iterate
Unexecuted instantiation: mixed_andnot.c:container_iterate
Unexecuted instantiation: roaring64.c:container_iterate
1967
1968
static inline bool container_iterate64(const container_t *c, uint8_t type,
1969
                                       uint32_t base,
1970
                                       roaring_iterator64 iterator,
1971
0
                                       uint64_t high_bits, void *ptr) {
1972
0
    c = container_unwrap_shared(c, &type);
1973
0
    switch (type) {
1974
0
        case BITSET_CONTAINER_TYPE:
1975
0
            return bitset_container_iterate64(const_CAST_bitset(c), base,
1976
0
                                              iterator, high_bits, ptr);
1977
0
        case ARRAY_CONTAINER_TYPE:
1978
0
            return array_container_iterate64(const_CAST_array(c), base,
1979
0
                                             iterator, high_bits, ptr);
1980
0
        case RUN_CONTAINER_TYPE:
1981
0
            return run_container_iterate64(const_CAST_run(c), base, iterator,
1982
0
                                           high_bits, ptr);
1983
0
        default:
1984
0
            assert(false);
1985
0
            roaring_unreachable;
1986
0
    }
1987
0
    assert(false);
1988
0
    roaring_unreachable;
1989
0
    return false;
1990
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_iterate64(roaring::api::container_s const*, unsigned char, unsigned int, bool (*)(unsigned long, void*), unsigned long, void*)
Unexecuted instantiation: roaring.c:container_iterate64
Unexecuted instantiation: roaring_array.c:container_iterate64
Unexecuted instantiation: containers.c:container_iterate64
Unexecuted instantiation: convert.c:container_iterate64
Unexecuted instantiation: mixed_negation.c:container_iterate64
Unexecuted instantiation: mixed_xor.c:container_iterate64
Unexecuted instantiation: mixed_andnot.c:container_iterate64
Unexecuted instantiation: roaring64.c:container_iterate64
1991
1992
static inline container_t *container_not(const container_t *c, uint8_t type,
1993
0
                                         uint8_t *result_type) {
1994
0
    c = container_unwrap_shared(c, &type);
1995
0
    container_t *result = NULL;
1996
0
    switch (type) {
1997
0
        case BITSET_CONTAINER_TYPE:
1998
0
            *result_type =
1999
0
                bitset_container_negation(const_CAST_bitset(c), &result)
2000
0
                    ? BITSET_CONTAINER_TYPE
2001
0
                    : ARRAY_CONTAINER_TYPE;
2002
0
            return result;
2003
0
        case ARRAY_CONTAINER_TYPE:
2004
0
            result = bitset_container_create();
2005
0
            *result_type = BITSET_CONTAINER_TYPE;
2006
0
            array_container_negation(const_CAST_array(c), CAST_bitset(result));
2007
0
            return result;
2008
0
        case RUN_CONTAINER_TYPE:
2009
0
            *result_type =
2010
0
                (uint8_t)run_container_negation(const_CAST_run(c), &result);
2011
0
            return result;
2012
2013
0
        default:
2014
0
            assert(false);
2015
0
            roaring_unreachable;
2016
0
    }
2017
0
    assert(false);
2018
0
    roaring_unreachable;
2019
0
    return NULL;
2020
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_not(roaring::api::container_s const*, unsigned char, unsigned char*)
Unexecuted instantiation: roaring.c:container_not
Unexecuted instantiation: roaring_array.c:container_not
Unexecuted instantiation: containers.c:container_not
Unexecuted instantiation: convert.c:container_not
Unexecuted instantiation: mixed_negation.c:container_not
Unexecuted instantiation: mixed_xor.c:container_not
Unexecuted instantiation: mixed_andnot.c:container_not
Unexecuted instantiation: roaring64.c:container_not
2021
2022
static inline container_t *container_not_range(const container_t *c,
2023
                                               uint8_t type,
2024
                                               uint32_t range_start,
2025
                                               uint32_t range_end,
2026
0
                                               uint8_t *result_type) {
2027
0
    c = container_unwrap_shared(c, &type);
2028
0
    container_t *result = NULL;
2029
0
    switch (type) {
2030
0
        case BITSET_CONTAINER_TYPE:
2031
0
            *result_type =
2032
0
                bitset_container_negation_range(const_CAST_bitset(c),
2033
0
                                                range_start, range_end, &result)
2034
0
                    ? BITSET_CONTAINER_TYPE
2035
0
                    : ARRAY_CONTAINER_TYPE;
2036
0
            return result;
2037
0
        case ARRAY_CONTAINER_TYPE:
2038
0
            *result_type =
2039
0
                array_container_negation_range(const_CAST_array(c), range_start,
2040
0
                                               range_end, &result)
2041
0
                    ? BITSET_CONTAINER_TYPE
2042
0
                    : ARRAY_CONTAINER_TYPE;
2043
0
            return result;
2044
0
        case RUN_CONTAINER_TYPE:
2045
0
            *result_type = (uint8_t)run_container_negation_range(
2046
0
                const_CAST_run(c), range_start, range_end, &result);
2047
0
            return result;
2048
2049
0
        default:
2050
0
            assert(false);
2051
0
            roaring_unreachable;
2052
0
    }
2053
0
    assert(false);
2054
0
    roaring_unreachable;
2055
0
    return NULL;
2056
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_not_range(roaring::api::container_s const*, unsigned char, unsigned int, unsigned int, unsigned char*)
Unexecuted instantiation: roaring.c:container_not_range
Unexecuted instantiation: roaring_array.c:container_not_range
Unexecuted instantiation: containers.c:container_not_range
Unexecuted instantiation: convert.c:container_not_range
Unexecuted instantiation: mixed_negation.c:container_not_range
Unexecuted instantiation: mixed_xor.c:container_not_range
Unexecuted instantiation: mixed_andnot.c:container_not_range
Unexecuted instantiation: roaring64.c:container_not_range
2057
2058
static inline container_t *container_inot(container_t *c, uint8_t type,
2059
7.57k
                                          uint8_t *result_type) {
2060
7.57k
    c = get_writable_copy_if_shared(c, &type);
2061
7.57k
    container_t *result = NULL;
2062
7.57k
    switch (type) {
2063
81
        case BITSET_CONTAINER_TYPE:
2064
81
            *result_type =
2065
81
                bitset_container_negation_inplace(CAST_bitset(c), &result)
2066
81
                    ? BITSET_CONTAINER_TYPE
2067
81
                    : ARRAY_CONTAINER_TYPE;
2068
81
            return result;
2069
138
        case ARRAY_CONTAINER_TYPE:
2070
            // will never be inplace
2071
138
            result = bitset_container_create();
2072
138
            *result_type = BITSET_CONTAINER_TYPE;
2073
138
            array_container_negation(CAST_array(c), CAST_bitset(result));
2074
138
            array_container_free(CAST_array(c));
2075
138
            return result;
2076
7.35k
        case RUN_CONTAINER_TYPE:
2077
7.35k
            *result_type =
2078
7.35k
                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
2079
7.35k
            return result;
2080
2081
0
        default:
2082
0
            assert(false);
2083
0
            roaring_unreachable;
2084
7.57k
    }
2085
0
    assert(false);
2086
0
    roaring_unreachable;
2087
0
    return NULL;
2088
7.57k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_inot(roaring::api::container_s*, unsigned char, unsigned char*)
roaring.c:container_inot
Line
Count
Source
2059
7.57k
                                          uint8_t *result_type) {
2060
7.57k
    c = get_writable_copy_if_shared(c, &type);
2061
7.57k
    container_t *result = NULL;
2062
7.57k
    switch (type) {
2063
81
        case BITSET_CONTAINER_TYPE:
2064
81
            *result_type =
2065
81
                bitset_container_negation_inplace(CAST_bitset(c), &result)
2066
81
                    ? BITSET_CONTAINER_TYPE
2067
81
                    : ARRAY_CONTAINER_TYPE;
2068
81
            return result;
2069
138
        case ARRAY_CONTAINER_TYPE:
2070
            // will never be inplace
2071
138
            result = bitset_container_create();
2072
138
            *result_type = BITSET_CONTAINER_TYPE;
2073
138
            array_container_negation(CAST_array(c), CAST_bitset(result));
2074
138
            array_container_free(CAST_array(c));
2075
138
            return result;
2076
7.35k
        case RUN_CONTAINER_TYPE:
2077
7.35k
            *result_type =
2078
7.35k
                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
2079
7.35k
            return result;
2080
2081
0
        default:
2082
0
            assert(false);
2083
0
            roaring_unreachable;
2084
7.57k
    }
2085
0
    assert(false);
2086
0
    roaring_unreachable;
2087
0
    return NULL;
2088
7.57k
}
Unexecuted instantiation: roaring_array.c:container_inot
Unexecuted instantiation: containers.c:container_inot
Unexecuted instantiation: convert.c:container_inot
Unexecuted instantiation: mixed_negation.c:container_inot
Unexecuted instantiation: mixed_xor.c:container_inot
Unexecuted instantiation: mixed_andnot.c:container_inot
Unexecuted instantiation: roaring64.c:container_inot
2089
2090
static inline container_t *container_inot_range(container_t *c, uint8_t type,
2091
                                                uint32_t range_start,
2092
                                                uint32_t range_end,
2093
5.44k
                                                uint8_t *result_type) {
2094
5.44k
    c = get_writable_copy_if_shared(c, &type);
2095
5.44k
    container_t *result = NULL;
2096
5.44k
    switch (type) {
2097
1.00k
        case BITSET_CONTAINER_TYPE:
2098
1.00k
            *result_type = bitset_container_negation_range_inplace(
2099
1.00k
                               CAST_bitset(c), range_start, range_end, &result)
2100
1.00k
                               ? BITSET_CONTAINER_TYPE
2101
1.00k
                               : ARRAY_CONTAINER_TYPE;
2102
1.00k
            return result;
2103
2.92k
        case ARRAY_CONTAINER_TYPE:
2104
2.92k
            *result_type = array_container_negation_range_inplace(
2105
2.92k
                               CAST_array(c), range_start, range_end, &result)
2106
2.92k
                               ? BITSET_CONTAINER_TYPE
2107
2.92k
                               : ARRAY_CONTAINER_TYPE;
2108
2.92k
            return result;
2109
1.51k
        case RUN_CONTAINER_TYPE:
2110
1.51k
            *result_type = (uint8_t)run_container_negation_range_inplace(
2111
1.51k
                CAST_run(c), range_start, range_end, &result);
2112
1.51k
            return result;
2113
2114
0
        default:
2115
0
            assert(false);
2116
0
            roaring_unreachable;
2117
5.44k
    }
2118
0
    assert(false);
2119
0
    roaring_unreachable;
2120
0
    return NULL;
2121
5.44k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_inot_range(roaring::api::container_s*, unsigned char, unsigned int, unsigned int, unsigned char*)
roaring.c:container_inot_range
Line
Count
Source
2093
5.44k
                                                uint8_t *result_type) {
2094
5.44k
    c = get_writable_copy_if_shared(c, &type);
2095
5.44k
    container_t *result = NULL;
2096
5.44k
    switch (type) {
2097
1.00k
        case BITSET_CONTAINER_TYPE:
2098
1.00k
            *result_type = bitset_container_negation_range_inplace(
2099
1.00k
                               CAST_bitset(c), range_start, range_end, &result)
2100
1.00k
                               ? BITSET_CONTAINER_TYPE
2101
1.00k
                               : ARRAY_CONTAINER_TYPE;
2102
1.00k
            return result;
2103
2.92k
        case ARRAY_CONTAINER_TYPE:
2104
2.92k
            *result_type = array_container_negation_range_inplace(
2105
2.92k
                               CAST_array(c), range_start, range_end, &result)
2106
2.92k
                               ? BITSET_CONTAINER_TYPE
2107
2.92k
                               : ARRAY_CONTAINER_TYPE;
2108
2.92k
            return result;
2109
1.51k
        case RUN_CONTAINER_TYPE:
2110
1.51k
            *result_type = (uint8_t)run_container_negation_range_inplace(
2111
1.51k
                CAST_run(c), range_start, range_end, &result);
2112
1.51k
            return result;
2113
2114
0
        default:
2115
0
            assert(false);
2116
0
            roaring_unreachable;
2117
5.44k
    }
2118
0
    assert(false);
2119
0
    roaring_unreachable;
2120
0
    return NULL;
2121
5.44k
}
Unexecuted instantiation: roaring_array.c:container_inot_range
Unexecuted instantiation: containers.c:container_inot_range
Unexecuted instantiation: convert.c:container_inot_range
Unexecuted instantiation: mixed_negation.c:container_inot_range
Unexecuted instantiation: mixed_xor.c:container_inot_range
Unexecuted instantiation: mixed_andnot.c:container_inot_range
Unexecuted instantiation: roaring64.c:container_inot_range
2122
2123
/**
2124
 * If the element of given rank is in this container, supposing that
2125
 * the first
2126
 * element has rank start_rank, then the function returns true and
2127
 * sets element
2128
 * accordingly.
2129
 * Otherwise, it returns false and update start_rank.
2130
 */
2131
static inline bool container_select(const container_t *c, uint8_t type,
2132
                                    uint32_t *start_rank, uint32_t rank,
2133
5.36k
                                    uint32_t *element) {
2134
5.36k
    c = container_unwrap_shared(c, &type);
2135
5.36k
    switch (type) {
2136
0
        case BITSET_CONTAINER_TYPE:
2137
0
            return bitset_container_select(const_CAST_bitset(c), start_rank,
2138
0
                                           rank, element);
2139
3.29k
        case ARRAY_CONTAINER_TYPE:
2140
3.29k
            return array_container_select(const_CAST_array(c), start_rank, rank,
2141
3.29k
                                          element);
2142
2.07k
        case RUN_CONTAINER_TYPE:
2143
2.07k
            return run_container_select(const_CAST_run(c), start_rank, rank,
2144
2.07k
                                        element);
2145
0
        default:
2146
0
            assert(false);
2147
0
            roaring_unreachable;
2148
5.36k
    }
2149
0
    assert(false);
2150
0
    roaring_unreachable;
2151
0
    return false;
2152
5.36k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_select(roaring::api::container_s const*, unsigned char, unsigned int*, unsigned int, unsigned int*)
roaring.c:container_select
Line
Count
Source
2133
5.36k
                                    uint32_t *element) {
2134
5.36k
    c = container_unwrap_shared(c, &type);
2135
5.36k
    switch (type) {
2136
0
        case BITSET_CONTAINER_TYPE:
2137
0
            return bitset_container_select(const_CAST_bitset(c), start_rank,
2138
0
                                           rank, element);
2139
3.29k
        case ARRAY_CONTAINER_TYPE:
2140
3.29k
            return array_container_select(const_CAST_array(c), start_rank, rank,
2141
3.29k
                                          element);
2142
2.07k
        case RUN_CONTAINER_TYPE:
2143
2.07k
            return run_container_select(const_CAST_run(c), start_rank, rank,
2144
2.07k
                                        element);
2145
0
        default:
2146
0
            assert(false);
2147
0
            roaring_unreachable;
2148
5.36k
    }
2149
0
    assert(false);
2150
0
    roaring_unreachable;
2151
0
    return false;
2152
5.36k
}
Unexecuted instantiation: roaring_array.c:container_select
Unexecuted instantiation: containers.c:container_select
Unexecuted instantiation: convert.c:container_select
Unexecuted instantiation: mixed_negation.c:container_select
Unexecuted instantiation: mixed_xor.c:container_select
Unexecuted instantiation: mixed_andnot.c:container_select
Unexecuted instantiation: roaring64.c:container_select
2153
2154
15.8k
static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
2155
15.8k
    c = container_unwrap_shared(c, &type);
2156
15.8k
    switch (type) {
2157
3.53k
        case BITSET_CONTAINER_TYPE:
2158
3.53k
            return bitset_container_maximum(const_CAST_bitset(c));
2159
11.0k
        case ARRAY_CONTAINER_TYPE:
2160
11.0k
            return array_container_maximum(const_CAST_array(c));
2161
1.32k
        case RUN_CONTAINER_TYPE:
2162
1.32k
            return run_container_maximum(const_CAST_run(c));
2163
0
        default:
2164
0
            assert(false);
2165
0
            roaring_unreachable;
2166
15.8k
    }
2167
0
    assert(false);
2168
0
    roaring_unreachable;
2169
0
    return false;
2170
15.8k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_maximum(roaring::api::container_s const*, unsigned char)
roaring.c:container_maximum
Line
Count
Source
2154
10.6k
static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
2155
10.6k
    c = container_unwrap_shared(c, &type);
2156
10.6k
    switch (type) {
2157
1.99k
        case BITSET_CONTAINER_TYPE:
2158
1.99k
            return bitset_container_maximum(const_CAST_bitset(c));
2159
7.29k
        case ARRAY_CONTAINER_TYPE:
2160
7.29k
            return array_container_maximum(const_CAST_array(c));
2161
1.32k
        case RUN_CONTAINER_TYPE:
2162
1.32k
            return run_container_maximum(const_CAST_run(c));
2163
0
        default:
2164
0
            assert(false);
2165
0
            roaring_unreachable;
2166
10.6k
    }
2167
0
    assert(false);
2168
0
    roaring_unreachable;
2169
0
    return false;
2170
10.6k
}
Unexecuted instantiation: roaring_array.c:container_maximum
containers.c:container_maximum
Line
Count
Source
2154
5.26k
static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
2155
5.26k
    c = container_unwrap_shared(c, &type);
2156
5.26k
    switch (type) {
2157
1.54k
        case BITSET_CONTAINER_TYPE:
2158
1.54k
            return bitset_container_maximum(const_CAST_bitset(c));
2159
3.72k
        case ARRAY_CONTAINER_TYPE:
2160
3.72k
            return array_container_maximum(const_CAST_array(c));
2161
0
        case RUN_CONTAINER_TYPE:
2162
0
            return run_container_maximum(const_CAST_run(c));
2163
0
        default:
2164
0
            assert(false);
2165
0
            roaring_unreachable;
2166
5.26k
    }
2167
0
    assert(false);
2168
0
    roaring_unreachable;
2169
0
    return false;
2170
5.26k
}
Unexecuted instantiation: convert.c:container_maximum
Unexecuted instantiation: mixed_negation.c:container_maximum
Unexecuted instantiation: mixed_xor.c:container_maximum
Unexecuted instantiation: mixed_andnot.c:container_maximum
Unexecuted instantiation: roaring64.c:container_maximum
2171
2172
5.32k
static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
2173
5.32k
    c = container_unwrap_shared(c, &type);
2174
5.32k
    switch (type) {
2175
981
        case BITSET_CONTAINER_TYPE:
2176
981
            return bitset_container_minimum(const_CAST_bitset(c));
2177
3.04k
        case ARRAY_CONTAINER_TYPE:
2178
3.04k
            return array_container_minimum(const_CAST_array(c));
2179
1.29k
        case RUN_CONTAINER_TYPE:
2180
1.29k
            return run_container_minimum(const_CAST_run(c));
2181
0
        default:
2182
0
            assert(false);
2183
0
            roaring_unreachable;
2184
5.32k
    }
2185
0
    assert(false);
2186
0
    roaring_unreachable;
2187
0
    return false;
2188
5.32k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_minimum(roaring::api::container_s const*, unsigned char)
roaring.c:container_minimum
Line
Count
Source
2172
5.32k
static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
2173
5.32k
    c = container_unwrap_shared(c, &type);
2174
5.32k
    switch (type) {
2175
981
        case BITSET_CONTAINER_TYPE:
2176
981
            return bitset_container_minimum(const_CAST_bitset(c));
2177
3.04k
        case ARRAY_CONTAINER_TYPE:
2178
3.04k
            return array_container_minimum(const_CAST_array(c));
2179
1.29k
        case RUN_CONTAINER_TYPE:
2180
1.29k
            return run_container_minimum(const_CAST_run(c));
2181
0
        default:
2182
0
            assert(false);
2183
0
            roaring_unreachable;
2184
5.32k
    }
2185
0
    assert(false);
2186
0
    roaring_unreachable;
2187
0
    return false;
2188
5.32k
}
Unexecuted instantiation: roaring_array.c:container_minimum
Unexecuted instantiation: containers.c:container_minimum
Unexecuted instantiation: convert.c:container_minimum
Unexecuted instantiation: mixed_negation.c:container_minimum
Unexecuted instantiation: mixed_xor.c:container_minimum
Unexecuted instantiation: mixed_andnot.c:container_minimum
Unexecuted instantiation: roaring64.c:container_minimum
2189
2190
// number of values smaller or equal to x
2191
static inline int container_rank(const container_t *c, uint8_t type,
2192
5.36k
                                 uint16_t x) {
2193
5.36k
    c = container_unwrap_shared(c, &type);
2194
5.36k
    switch (type) {
2195
0
        case BITSET_CONTAINER_TYPE:
2196
0
            return bitset_container_rank(const_CAST_bitset(c), x);
2197
3.29k
        case ARRAY_CONTAINER_TYPE:
2198
3.29k
            return array_container_rank(const_CAST_array(c), x);
2199
2.07k
        case RUN_CONTAINER_TYPE:
2200
2.07k
            return run_container_rank(const_CAST_run(c), x);
2201
0
        default:
2202
0
            assert(false);
2203
0
            roaring_unreachable;
2204
5.36k
    }
2205
0
    assert(false);
2206
0
    roaring_unreachable;
2207
0
    return false;
2208
5.36k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_rank(roaring::api::container_s const*, unsigned char, unsigned short)
roaring.c:container_rank
Line
Count
Source
2192
5.36k
                                 uint16_t x) {
2193
5.36k
    c = container_unwrap_shared(c, &type);
2194
5.36k
    switch (type) {
2195
0
        case BITSET_CONTAINER_TYPE:
2196
0
            return bitset_container_rank(const_CAST_bitset(c), x);
2197
3.29k
        case ARRAY_CONTAINER_TYPE:
2198
3.29k
            return array_container_rank(const_CAST_array(c), x);
2199
2.07k
        case RUN_CONTAINER_TYPE:
2200
2.07k
            return run_container_rank(const_CAST_run(c), x);
2201
0
        default:
2202
0
            assert(false);
2203
0
            roaring_unreachable;
2204
5.36k
    }
2205
0
    assert(false);
2206
0
    roaring_unreachable;
2207
0
    return false;
2208
5.36k
}
Unexecuted instantiation: roaring_array.c:container_rank
Unexecuted instantiation: containers.c:container_rank
Unexecuted instantiation: convert.c:container_rank
Unexecuted instantiation: mixed_negation.c:container_rank
Unexecuted instantiation: mixed_xor.c:container_rank
Unexecuted instantiation: mixed_andnot.c:container_rank
Unexecuted instantiation: roaring64.c:container_rank
2209
2210
// bulk version of container_rank(); return number of consumed elements
2211
static inline uint32_t container_rank_many(const container_t *c, uint8_t type,
2212
                                           uint64_t start_rank,
2213
                                           const uint32_t *begin,
2214
0
                                           const uint32_t *end, uint64_t *ans) {
2215
0
    c = container_unwrap_shared(c, &type);
2216
0
    switch (type) {
2217
0
        case BITSET_CONTAINER_TYPE:
2218
0
            return bitset_container_rank_many(const_CAST_bitset(c), start_rank,
2219
0
                                              begin, end, ans);
2220
0
        case ARRAY_CONTAINER_TYPE:
2221
0
            return array_container_rank_many(const_CAST_array(c), start_rank,
2222
0
                                             begin, end, ans);
2223
0
        case RUN_CONTAINER_TYPE:
2224
0
            return run_container_rank_many(const_CAST_run(c), start_rank, begin,
2225
0
                                           end, ans);
2226
0
        default:
2227
0
            assert(false);
2228
0
            roaring_unreachable;
2229
0
    }
2230
0
    assert(false);
2231
0
    roaring_unreachable;
2232
0
    return 0;
2233
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_rank_many(roaring::api::container_s const*, unsigned char, unsigned long, unsigned int const*, unsigned int const*, unsigned long*)
Unexecuted instantiation: roaring.c:container_rank_many
Unexecuted instantiation: roaring_array.c:container_rank_many
Unexecuted instantiation: containers.c:container_rank_many
Unexecuted instantiation: convert.c:container_rank_many
Unexecuted instantiation: mixed_negation.c:container_rank_many
Unexecuted instantiation: mixed_xor.c:container_rank_many
Unexecuted instantiation: mixed_andnot.c:container_rank_many
Unexecuted instantiation: roaring64.c:container_rank_many
2234
2235
// return the index of x, if not exsist return -1
2236
static inline int container_get_index(const container_t *c, uint8_t type,
2237
0
                                      uint16_t x) {
2238
0
    c = container_unwrap_shared(c, &type);
2239
0
    switch (type) {
2240
0
        case BITSET_CONTAINER_TYPE:
2241
0
            return bitset_container_get_index(const_CAST_bitset(c), x);
2242
0
        case ARRAY_CONTAINER_TYPE:
2243
0
            return array_container_get_index(const_CAST_array(c), x);
2244
0
        case RUN_CONTAINER_TYPE:
2245
0
            return run_container_get_index(const_CAST_run(c), x);
2246
0
        default:
2247
0
            assert(false);
2248
0
            roaring_unreachable;
2249
0
    }
2250
0
    assert(false);
2251
0
    roaring_unreachable;
2252
0
    return false;
2253
0
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_get_index(roaring::api::container_s const*, unsigned char, unsigned short)
Unexecuted instantiation: roaring.c:container_get_index
Unexecuted instantiation: roaring_array.c:container_get_index
Unexecuted instantiation: containers.c:container_get_index
Unexecuted instantiation: convert.c:container_get_index
Unexecuted instantiation: mixed_negation.c:container_get_index
Unexecuted instantiation: mixed_xor.c:container_get_index
Unexecuted instantiation: mixed_andnot.c:container_get_index
Unexecuted instantiation: roaring64.c:container_get_index
2254
2255
/**
2256
 * Add all values in range [min, max] to a given container.
2257
 *
2258
 * If the returned pointer is different from $container, then a new container
2259
 * has been created and the caller is responsible for freeing it.
2260
 * The type of the first container may change. Returns the modified
2261
 * (and possibly new) container.
2262
 */
2263
static inline container_t *container_add_range(container_t *c, uint8_t type,
2264
                                               uint32_t min, uint32_t max,
2265
2.96k
                                               uint8_t *result_type) {
2266
    // NB: when selecting new container type, we perform only inexpensive checks
2267
2.96k
    switch (type) {
2268
0
        case BITSET_CONTAINER_TYPE: {
2269
0
            bitset_container_t *bitset = CAST_bitset(c);
2270
2271
0
            int32_t union_cardinality = 0;
2272
0
            union_cardinality += bitset->cardinality;
2273
0
            union_cardinality += max - min + 1;
2274
0
            union_cardinality -=
2275
0
                bitset_lenrange_cardinality(bitset->words, min, max - min);
2276
2277
0
            if (union_cardinality == INT32_C(0x10000)) {
2278
0
                *result_type = RUN_CONTAINER_TYPE;
2279
0
                return run_container_create_range(0, INT32_C(0x10000));
2280
0
            } else {
2281
0
                *result_type = BITSET_CONTAINER_TYPE;
2282
0
                bitset_set_lenrange(bitset->words, min, max - min);
2283
0
                bitset->cardinality = union_cardinality;
2284
0
                return bitset;
2285
0
            }
2286
0
        }
2287
2.59k
        case ARRAY_CONTAINER_TYPE: {
2288
2.59k
            array_container_t *array = CAST_array(c);
2289
2290
2.59k
            int32_t nvals_greater =
2291
2.59k
                count_greater(array->array, array->cardinality, (uint16_t)max);
2292
2.59k
            int32_t nvals_less =
2293
2.59k
                count_less(array->array, array->cardinality - nvals_greater,
2294
2.59k
                           (uint16_t)min);
2295
2.59k
            int32_t union_cardinality =
2296
2.59k
                nvals_less + (max - min + 1) + nvals_greater;
2297
2298
2.59k
            if (union_cardinality == INT32_C(0x10000)) {
2299
798
                *result_type = RUN_CONTAINER_TYPE;
2300
798
                return run_container_create_range(0, INT32_C(0x10000));
2301
1.79k
            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
2302
526
                *result_type = ARRAY_CONTAINER_TYPE;
2303
526
                array_container_add_range_nvals(array, min, max, nvals_less,
2304
526
                                                nvals_greater);
2305
526
                return array;
2306
1.27k
            } else {
2307
1.27k
                *result_type = BITSET_CONTAINER_TYPE;
2308
1.27k
                bitset_container_t *bitset = bitset_container_from_array(array);
2309
1.27k
                bitset_set_lenrange(bitset->words, min, max - min);
2310
1.27k
                bitset->cardinality = union_cardinality;
2311
1.27k
                return bitset;
2312
1.27k
            }
2313
2.59k
        }
2314
368
        case RUN_CONTAINER_TYPE: {
2315
368
            run_container_t *run = CAST_run(c);
2316
2317
368
            int32_t nruns_greater =
2318
368
                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
2319
368
            int32_t nruns_less = rle16_count_less(
2320
368
                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
2321
2322
368
            int32_t run_size_bytes =
2323
368
                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
2324
368
            int32_t bitset_size_bytes =
2325
368
                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
2326
2327
368
            if (run_size_bytes <= bitset_size_bytes) {
2328
368
                run_container_add_range_nruns(run, min, max, nruns_less,
2329
368
                                              nruns_greater);
2330
368
                *result_type = RUN_CONTAINER_TYPE;
2331
368
                return run;
2332
368
            } else {
2333
0
                return container_from_run_range(run, min, max, result_type);
2334
0
            }
2335
368
        }
2336
0
        default:
2337
0
            roaring_unreachable;
2338
2.96k
    }
2339
2.96k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_add_range(roaring::api::container_s*, unsigned char, unsigned int, unsigned int, unsigned char*)
roaring.c:container_add_range
Line
Count
Source
2265
2.96k
                                               uint8_t *result_type) {
2266
    // NB: when selecting new container type, we perform only inexpensive checks
2267
2.96k
    switch (type) {
2268
0
        case BITSET_CONTAINER_TYPE: {
2269
0
            bitset_container_t *bitset = CAST_bitset(c);
2270
2271
0
            int32_t union_cardinality = 0;
2272
0
            union_cardinality += bitset->cardinality;
2273
0
            union_cardinality += max - min + 1;
2274
0
            union_cardinality -=
2275
0
                bitset_lenrange_cardinality(bitset->words, min, max - min);
2276
2277
0
            if (union_cardinality == INT32_C(0x10000)) {
2278
0
                *result_type = RUN_CONTAINER_TYPE;
2279
0
                return run_container_create_range(0, INT32_C(0x10000));
2280
0
            } else {
2281
0
                *result_type = BITSET_CONTAINER_TYPE;
2282
0
                bitset_set_lenrange(bitset->words, min, max - min);
2283
0
                bitset->cardinality = union_cardinality;
2284
0
                return bitset;
2285
0
            }
2286
0
        }
2287
2.59k
        case ARRAY_CONTAINER_TYPE: {
2288
2.59k
            array_container_t *array = CAST_array(c);
2289
2290
2.59k
            int32_t nvals_greater =
2291
2.59k
                count_greater(array->array, array->cardinality, (uint16_t)max);
2292
2.59k
            int32_t nvals_less =
2293
2.59k
                count_less(array->array, array->cardinality - nvals_greater,
2294
2.59k
                           (uint16_t)min);
2295
2.59k
            int32_t union_cardinality =
2296
2.59k
                nvals_less + (max - min + 1) + nvals_greater;
2297
2298
2.59k
            if (union_cardinality == INT32_C(0x10000)) {
2299
798
                *result_type = RUN_CONTAINER_TYPE;
2300
798
                return run_container_create_range(0, INT32_C(0x10000));
2301
1.79k
            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
2302
526
                *result_type = ARRAY_CONTAINER_TYPE;
2303
526
                array_container_add_range_nvals(array, min, max, nvals_less,
2304
526
                                                nvals_greater);
2305
526
                return array;
2306
1.27k
            } else {
2307
1.27k
                *result_type = BITSET_CONTAINER_TYPE;
2308
1.27k
                bitset_container_t *bitset = bitset_container_from_array(array);
2309
1.27k
                bitset_set_lenrange(bitset->words, min, max - min);
2310
1.27k
                bitset->cardinality = union_cardinality;
2311
1.27k
                return bitset;
2312
1.27k
            }
2313
2.59k
        }
2314
368
        case RUN_CONTAINER_TYPE: {
2315
368
            run_container_t *run = CAST_run(c);
2316
2317
368
            int32_t nruns_greater =
2318
368
                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
2319
368
            int32_t nruns_less = rle16_count_less(
2320
368
                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
2321
2322
368
            int32_t run_size_bytes =
2323
368
                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
2324
368
            int32_t bitset_size_bytes =
2325
368
                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
2326
2327
368
            if (run_size_bytes <= bitset_size_bytes) {
2328
368
                run_container_add_range_nruns(run, min, max, nruns_less,
2329
368
                                              nruns_greater);
2330
368
                *result_type = RUN_CONTAINER_TYPE;
2331
368
                return run;
2332
368
            } else {
2333
0
                return container_from_run_range(run, min, max, result_type);
2334
0
            }
2335
368
        }
2336
0
        default:
2337
0
            roaring_unreachable;
2338
2.96k
    }
2339
2.96k
}
Unexecuted instantiation: roaring_array.c:container_add_range
Unexecuted instantiation: containers.c:container_add_range
Unexecuted instantiation: convert.c:container_add_range
Unexecuted instantiation: mixed_negation.c:container_add_range
Unexecuted instantiation: mixed_xor.c:container_add_range
Unexecuted instantiation: mixed_andnot.c:container_add_range
Unexecuted instantiation: roaring64.c:container_add_range
2340
2341
/*
2342
 * Removes all elements in range [min, max].
2343
 * Returns one of:
2344
 *   - NULL if no elements left
2345
 *   - pointer to the original container
2346
 *   - pointer to a newly-allocated container (if it is more efficient)
2347
 *
2348
 * If the returned pointer is different from $container, then a new container
2349
 * has been created and the caller is responsible for freeing the original
2350
 * container.
2351
 */
2352
static inline container_t *container_remove_range(container_t *c, uint8_t type,
2353
                                                  uint32_t min, uint32_t max,
2354
19.0k
                                                  uint8_t *result_type) {
2355
19.0k
    switch (type) {
2356
1.01k
        case BITSET_CONTAINER_TYPE: {
2357
1.01k
            bitset_container_t *bitset = CAST_bitset(c);
2358
2359
1.01k
            int32_t result_cardinality =
2360
1.01k
                bitset->cardinality -
2361
1.01k
                bitset_lenrange_cardinality(bitset->words, min, max - min);
2362
2363
1.01k
            if (result_cardinality == 0) {
2364
40
                return NULL;
2365
970
            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
2366
93
                *result_type = ARRAY_CONTAINER_TYPE;
2367
93
                bitset_reset_range(bitset->words, min, max + 1);
2368
93
                bitset->cardinality = result_cardinality;
2369
93
                return array_container_from_bitset(bitset);
2370
877
            } else {
2371
877
                *result_type = BITSET_CONTAINER_TYPE;
2372
877
                bitset_reset_range(bitset->words, min, max + 1);
2373
877
                bitset->cardinality = result_cardinality;
2374
877
                return bitset;
2375
877
            }
2376
1.01k
        }
2377
2.98k
        case ARRAY_CONTAINER_TYPE: {
2378
2.98k
            array_container_t *array = CAST_array(c);
2379
2380
2.98k
            int32_t nvals_greater =
2381
2.98k
                count_greater(array->array, array->cardinality, (uint16_t)max);
2382
2.98k
            int32_t nvals_less =
2383
2.98k
                count_less(array->array, array->cardinality - nvals_greater,
2384
2.98k
                           (uint16_t)min);
2385
2.98k
            int32_t result_cardinality = nvals_less + nvals_greater;
2386
2387
2.98k
            if (result_cardinality == 0) {
2388
338
                return NULL;
2389
2.64k
            } else {
2390
2.64k
                *result_type = ARRAY_CONTAINER_TYPE;
2391
2.64k
                array_container_remove_range(
2392
2.64k
                    array, nvals_less, array->cardinality - result_cardinality);
2393
2.64k
                return array;
2394
2.64k
            }
2395
2.98k
        }
2396
15.1k
        case RUN_CONTAINER_TYPE: {
2397
15.1k
            run_container_t *run = CAST_run(c);
2398
2399
15.1k
            if (run->n_runs == 0) {
2400
0
                return NULL;
2401
0
            }
2402
15.1k
            if (min <= run_container_minimum(run) &&
2403
15.1k
                max >= run_container_maximum(run)) {
2404
13.5k
                return NULL;
2405
13.5k
            }
2406
2407
1.56k
            run_container_remove_range(run, min, max);
2408
1.56k
            return convert_run_to_efficient_container(run, result_type);
2409
15.1k
        }
2410
0
        default:
2411
0
            roaring_unreachable;
2412
19.0k
    }
2413
19.0k
}
Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::container_remove_range(roaring::api::container_s*, unsigned char, unsigned int, unsigned int, unsigned char*)
roaring.c:container_remove_range
Line
Count
Source
2354
19.0k
                                                  uint8_t *result_type) {
2355
19.0k
    switch (type) {
2356
1.01k
        case BITSET_CONTAINER_TYPE: {
2357
1.01k
            bitset_container_t *bitset = CAST_bitset(c);
2358
2359
1.01k
            int32_t result_cardinality =
2360
1.01k
                bitset->cardinality -
2361
1.01k
                bitset_lenrange_cardinality(bitset->words, min, max - min);
2362
2363
1.01k
            if (result_cardinality == 0) {
2364
40
                return NULL;
2365
970
            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
2366
93
                *result_type = ARRAY_CONTAINER_TYPE;
2367
93
                bitset_reset_range(bitset->words, min, max + 1);
2368
93
                bitset->cardinality = result_cardinality;
2369
93
                return array_container_from_bitset(bitset);
2370
877
            } else {
2371
877
                *result_type = BITSET_CONTAINER_TYPE;
2372
877
                bitset_reset_range(bitset->words, min, max + 1);
2373
877
                bitset->cardinality = result_cardinality;
2374
877
                return bitset;
2375
877
            }
2376
1.01k
        }
2377
2.98k
        case ARRAY_CONTAINER_TYPE: {
2378
2.98k
            array_container_t *array = CAST_array(c);
2379
2380
2.98k
            int32_t nvals_greater =
2381
2.98k
                count_greater(array->array, array->cardinality, (uint16_t)max);
2382
2.98k
            int32_t nvals_less =
2383
2.98k
                count_less(array->array, array->cardinality - nvals_greater,
2384
2.98k
                           (uint16_t)min);
2385
2.98k
            int32_t result_cardinality = nvals_less + nvals_greater;
2386
2387
2.98k
            if (result_cardinality == 0) {
2388
338
                return NULL;
2389
2.64k
            } else {
2390
2.64k
                *result_type = ARRAY_CONTAINER_TYPE;
2391
2.64k
                array_container_remove_range(
2392
2.64k
                    array, nvals_less, array->cardinality - result_cardinality);
2393
2.64k
                return array;
2394
2.64k
            }
2395
2.98k
        }
2396
15.1k
        case RUN_CONTAINER_TYPE: {
2397
15.1k
            run_container_t *run = CAST_run(c);
2398
2399
15.1k
            if (run->n_runs == 0) {
2400
0
                return NULL;
2401
0
            }
2402
15.1k
            if (min <= run_container_minimum(run) &&
2403
15.1k
                max >= run_container_maximum(run)) {
2404
13.5k
                return NULL;
2405
13.5k
            }
2406
2407
1.56k
            run_container_remove_range(run, min, max);
2408
1.56k
            return convert_run_to_efficient_container(run, result_type);
2409
15.1k
        }
2410
0
        default:
2411
0
            roaring_unreachable;
2412
19.0k
    }
2413
19.0k
}
Unexecuted instantiation: roaring_array.c:container_remove_range
Unexecuted instantiation: containers.c:container_remove_range
Unexecuted instantiation: convert.c:container_remove_range
Unexecuted instantiation: mixed_negation.c:container_remove_range
Unexecuted instantiation: mixed_xor.c:container_remove_range
Unexecuted instantiation: mixed_andnot.c:container_remove_range
Unexecuted instantiation: roaring64.c:container_remove_range
2414
2415
#ifdef __cplusplus
2416
using api::roaring_container_iterator_t;
2417
#endif
2418
2419
/**
2420
 * Initializes the iterator at the first entry in the container.
2421
 */
2422
roaring_container_iterator_t container_init_iterator(const container_t *c,
2423
                                                     uint8_t typecode,
2424
                                                     uint16_t *value);
2425
2426
/**
2427
 * Initializes the iterator at the last entry in the container.
2428
 */
2429
roaring_container_iterator_t container_init_iterator_last(const container_t *c,
2430
                                                          uint8_t typecode,
2431
                                                          uint16_t *value);
2432
2433
/**
2434
 * Moves the iterator to the next entry. Returns true and sets `value` if a
2435
 * value is present.
2436
 */
2437
bool container_iterator_next(const container_t *c, uint8_t typecode,
2438
                             roaring_container_iterator_t *it, uint16_t *value);
2439
2440
/**
2441
 * Moves the iterator to the previous entry. Returns true and sets `value` if a
2442
 * value is present.
2443
 */
2444
bool container_iterator_prev(const container_t *c, uint8_t typecode,
2445
                             roaring_container_iterator_t *it, uint16_t *value);
2446
2447
/**
2448
 * Moves the iterator to the smallest entry that is greater than or equal to
2449
 * `val`. Returns true and sets `value_out` if a value is present. `value_out`
2450
 * should be initialized to a value.
2451
 */
2452
bool container_iterator_lower_bound(const container_t *c, uint8_t typecode,
2453
                                    roaring_container_iterator_t *it,
2454
                                    uint16_t *value_out, uint16_t val);
2455
2456
/**
2457
 * Reads up to `count` entries from the container, and writes them into `buf`
2458
 * as `high16 | entry`. Returns true and sets `value_out` if a value is present
2459
 * after reading the entries. Sets `consumed` to the number of values read.
2460
 * `count` should be greater than zero.
2461
 */
2462
bool container_iterator_read_into_uint32(const container_t *c, uint8_t typecode,
2463
                                         roaring_container_iterator_t *it,
2464
                                         uint32_t high16, uint32_t *buf,
2465
                                         uint32_t count, uint32_t *consumed,
2466
                                         uint16_t *value_out);
2467
2468
/**
2469
 * Reads up to `count` entries from the container, and writes them into `buf`
2470
 * as `high48 | entry`. Returns true and sets `value_out` if a value is present
2471
 * after reading the entries. Sets `consumed` to the number of values read.
2472
 * `count` should be greater than zero.
2473
 */
2474
bool container_iterator_read_into_uint64(const container_t *c, uint8_t typecode,
2475
                                         roaring_container_iterator_t *it,
2476
                                         uint64_t high48, uint64_t *buf,
2477
                                         uint32_t count, uint32_t *consumed,
2478
                                         uint16_t *value_out);
2479
2480
#ifdef __cplusplus
2481
}
2482
}
2483
}  // extern "C" { namespace roaring { namespace internal {
2484
#endif
2485
2486
#endif