diff --git a/include/roaring/roaring64.h b/include/roaring/roaring64.h index 3685fcbb9..304babb5d 100644 --- a/include/roaring/roaring64.h +++ b/include/roaring/roaring64.h @@ -8,33 +8,14 @@ #include #include -// TODO: This is messy and can likely be improved. -#if defined(__cplusplus) -#define ROARING_ART_T ::roaring::internal::art_t -#define ROARING_ART_VAL_T ::roaring::internal::art_val_t -#else -#define ROARING_ART_T art_t -#define ROARING_ART_VAL_T art_val_t -#define ROARING_CONTAINER_T void -#endif - #ifdef __cplusplus extern "C" { namespace roaring { namespace api { #endif -typedef struct roaring64_bitmap_s { - ROARING_ART_T art; - uint8_t flags; -} roaring64_bitmap_t; - -// TODO: Ideally we don't put this in the header. -typedef struct leaf_s { - ROARING_ART_VAL_T _pad; - uint8_t typecode; - ROARING_CONTAINER_T *container; -} leaf_t; +typedef struct roaring64_bitmap_s roaring64_bitmap_t; +typedef struct roaring64_leaf_s roaring64_leaf_t; /** * A bit of context usable with `roaring64_bitmap_*_bulk()` functions. @@ -50,7 +31,7 @@ typedef struct leaf_s { typedef struct roaring64_bulk_context_s { uint8_t high_bytes[ART_KEY_BYTES]; uint16_t low_bytes; - leaf_t *leaf; + roaring64_leaf_t *leaf; } roaring64_bulk_context_t; /** diff --git a/src/roaring64.c b/src/roaring64.c index ffbbcb9bd..bf02af4a2 100644 --- a/src/roaring64.c +++ b/src/roaring64.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -41,10 +42,9 @@ using namespace ::roaring::internal; extern "C" { namespace roaring { -namespace api64 { +namespace api { #endif -// TODO: Figure out how to keep art_t from being exposed in roaring64.h // TODO: Iteration. // * Need to create a container iterator which can be used across 32 and 64 bit // bitmaps. @@ -53,6 +53,22 @@ namespace api64 { // TODO: Serialization. // TODO: Error on failed allocation. +typedef struct roaring64_bitmap_s { + art_t art; + uint8_t flags; +} roaring64_bitmap_t; + +// Leaf type of the ART used to keep the high 48 bits of each entry. +typedef struct roaring64_leaf_s { + art_val_t _pad; + uint8_t typecode; + container_t *container; +} roaring64_leaf_t; + +// Alias to make it easier to work with, since it's an internal-only type +// anyway. +typedef struct roaring64_leaf_s leaf_t; + // Splits the given uint64 key into high 48 bit and low 16 bit components. // Expects high48_out to be of length ART_KEY_BYTES. static inline uint16_t split_key(uint64_t key, uint8_t high48_out[]) {