alloc an extra bucket ptr as trailing sentinel value (for later usage)
parent
d7c789195a
commit
3613af3daa
|
@ -317,8 +317,8 @@ protected:
|
|||
FuncPair(hf, eqf))),
|
||||
p_maxlf(1.0f) {
|
||||
if (!size) return;
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), size);
|
||||
memset(p_data.first(), 0, size * sizeof(Chain *));
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), size + 1);
|
||||
memset(p_data.first(), 0, (size + 1) * sizeof(Chain *));
|
||||
}
|
||||
|
||||
Hashtable(const Hashtable &ht, const A &alloc): p_size(ht.p_size),
|
||||
|
@ -327,8 +327,8 @@ protected:
|
|||
FuncPair(ht.get_hash(), ht.get_eq()))),
|
||||
p_maxlf(ht.p_maxlf) {
|
||||
if (!p_size) return;
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), p_size);
|
||||
memset(p_data.first(), 0, p_size * sizeof(Chain *));
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), p_size + 1);
|
||||
memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *));
|
||||
Chain **och = ht.p_data.first();
|
||||
for (Size h = 0; h < p_size; ++h) {
|
||||
Chain *oc = och[h];
|
||||
|
@ -368,8 +368,8 @@ protected:
|
|||
p_len = 0;
|
||||
p_chunks = nullptr;
|
||||
p_unused = nullptr;
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), p_size);
|
||||
memset(p_data.first(), 0, p_size * sizeof(Chain *));
|
||||
p_data.first() = allocator_allocate(get_cpalloc(), p_size + 1);
|
||||
memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *));
|
||||
Chain **och = ht.p_data.first();
|
||||
for (Size h = 0; h < p_size; ++h) {
|
||||
Chain *oc = och[h];
|
||||
|
@ -385,10 +385,10 @@ protected:
|
|||
if (AllocatorPropagateOnContainerCopyAssignment<A>::value) {
|
||||
if ((get_cpalloc() != ht.get_cpalloc()) && p_size) {
|
||||
allocator_deallocate(get_cpalloc(),
|
||||
p_data.first(), p_size);
|
||||
p_data.first(), p_size + 1);
|
||||
p_data.first() = allocator_allocate(get_cpalloc(),
|
||||
p_size);
|
||||
memset(p_data.first(), 0, p_size * sizeof(Chain *));
|
||||
p_size + 1);
|
||||
memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *));
|
||||
}
|
||||
get_alloc() = ht.get_alloc();
|
||||
get_cpalloc() = ht.get_cpalloc();
|
||||
|
@ -437,7 +437,7 @@ protected:
|
|||
public:
|
||||
~Hashtable() {
|
||||
if (p_size) allocator_deallocate(get_cpalloc(),
|
||||
p_data.first(), p_size);
|
||||
p_data.first(), p_size + 1);
|
||||
delete_chunks(p_chunks);
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ public:
|
|||
|
||||
void clear() {
|
||||
if (!p_len) return;
|
||||
memset(p_data.first(), 0, p_size * sizeof(Chain *));
|
||||
memset(p_data.first(), 0, (p_size + 1) * sizeof(Chain *));
|
||||
p_len = 0;
|
||||
p_unused = nullptr;
|
||||
delete_chunks(p_chunks);
|
||||
|
@ -562,8 +562,8 @@ public:
|
|||
if (fbcount > count) count = fbcount;
|
||||
|
||||
Chain **och = p_data.first();
|
||||
Chain **nch = allocator_allocate(get_cpalloc(), count);
|
||||
memset(nch, 0, count * sizeof(Chain *));
|
||||
Chain **nch = allocator_allocate(get_cpalloc(), count + 1);
|
||||
memset(nch, 0, (count + 1) * sizeof(Chain *));
|
||||
p_data.first() = nch;
|
||||
|
||||
Size osize = p_size;
|
||||
|
|
Loading…
Reference in New Issue