From 53d212bf7fb4daa606588ffd2d031d2f818bbbd4 Mon Sep 17 00:00:00 2001 From: Tao He Date: Wed, 6 Sep 2023 18:48:47 +0800 Subject: [PATCH] Fixes the missing of copy ctor for bitset (#154) Signed-off-by: Tao He --- grape/utils/bitset.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grape/utils/bitset.h b/grape/utils/bitset.h index df039f28..223161f9 100644 --- a/grape/utils/bitset.h +++ b/grape/utils/bitset.h @@ -25,6 +25,7 @@ limitations under the License. #include "thread_pool.h" #define WORD_SIZE(n) (((n) + 63ul) >> 6) +#define BYTE_SIZE(n) (((n) + 63ul) >> 3) #define WORD_INDEX(i) ((i) >> 6) #define BIT_OFFSET(i) ((i) &0x3f) @@ -45,6 +46,12 @@ class Bitset : public Allocator { data_ = this->allocate(size_in_words_); clear(); } + Bitset(const Bitset& other) + : size_(other.size_), + size_in_words_(other.size_in_words_) { + data_ = this->allocate(size_in_words_); + memcpy(data_, other.data_, BYTE_SIZE(size_)); + } Bitset(Bitset&& other) : data_(other.data_), size_(other.size_), @@ -348,6 +355,7 @@ class RefBitset { }; #undef WORD_SIZE +#undef BYTE_SIZE #undef WORD_INDEX #undef BIT_OFFSET #undef ROUND_UP