Fix memory leaks in Map and Set
This commit is contained in:
parent
1aebf7703a
commit
0307a1d9be
|
@ -380,7 +380,9 @@ class Map {
|
|||
/// Copy constructor
|
||||
Map(const Map<K, V>& map)
|
||||
:mNbUsedEntries(map.mNbUsedEntries), mNbFreeEntries(map.mNbFreeEntries), mCapacity(map.mCapacity),
|
||||
mAllocator(map.mAllocator), mFreeIndex(map.mFreeIndex) {
|
||||
mBuckets(nullptr), mEntries(nullptr), mAllocator(map.mAllocator), mFreeIndex(map.mFreeIndex) {
|
||||
|
||||
if (mCapacity > 0) {
|
||||
|
||||
// Allocate memory for the buckets
|
||||
mBuckets = static_cast<int*>(mAllocator.allocate(mCapacity * sizeof(int)));
|
||||
|
@ -402,6 +404,7 @@ class Map {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~Map() {
|
||||
|
|
|
@ -379,7 +379,9 @@ class Set {
|
|||
/// Copy constructor
|
||||
Set(const Set<V>& set)
|
||||
:mNbUsedEntries(set.mNbUsedEntries), mNbFreeEntries(set.mNbFreeEntries), mCapacity(set.mCapacity),
|
||||
mAllocator(set.mAllocator), mFreeIndex(set.mFreeIndex) {
|
||||
mBuckets(nullptr), mEntries(nullptr), mAllocator(set.mAllocator), mFreeIndex(set.mFreeIndex) {
|
||||
|
||||
if (mCapacity > 0) {
|
||||
|
||||
// Allocate memory for the buckets
|
||||
mBuckets = static_cast<int*>(mAllocator.allocate(mCapacity * sizeof(int)));
|
||||
|
@ -401,6 +403,7 @@ class Set {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~Set() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user