[map] Destruct objects
This commit is contained in:
parent
726b1a8b2d
commit
956e0a4d13
|
@ -61,9 +61,6 @@ struct hb_hashmap_t
|
||||||
hb_copy (o, *this);
|
hb_copy (o, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert (std::is_trivially_destructible<K>::value, "");
|
|
||||||
static_assert (std::is_trivially_destructible<V>::value, "");
|
|
||||||
|
|
||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
K key;
|
K key;
|
||||||
|
@ -134,6 +131,9 @@ struct hb_hashmap_t
|
||||||
}
|
}
|
||||||
void fini_shallow ()
|
void fini_shallow ()
|
||||||
{
|
{
|
||||||
|
unsigned size = mask + 1;
|
||||||
|
for (unsigned i = 0; i < size; i++)
|
||||||
|
items[i].~item_t ();
|
||||||
hb_free (items);
|
hb_free (items);
|
||||||
items = nullptr;
|
items = nullptr;
|
||||||
population = occupancy = 0;
|
population = occupancy = 0;
|
||||||
|
@ -179,10 +179,15 @@ struct hb_hashmap_t
|
||||||
/* Insert back old items. */
|
/* Insert back old items. */
|
||||||
if (old_items)
|
if (old_items)
|
||||||
for (unsigned int i = 0; i < old_size; i++)
|
for (unsigned int i = 0; i < old_size; i++)
|
||||||
|
{
|
||||||
if (old_items[i].is_real ())
|
if (old_items[i].is_real ())
|
||||||
|
{
|
||||||
set_with_hash (old_items[i].key,
|
set_with_hash (old_items[i].key,
|
||||||
old_items[i].hash,
|
old_items[i].hash,
|
||||||
std::move (old_items[i].value));
|
std::move (old_items[i].value));
|
||||||
|
}
|
||||||
|
old_items[i].~item_t ();
|
||||||
|
}
|
||||||
|
|
||||||
hb_free (old_items);
|
hb_free (old_items);
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,6 @@ main (int argc, char **argv)
|
||||||
assert (m3.get_population () == 0);
|
assert (m3.get_population () == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
{
|
{
|
||||||
hb_hashmap_t<int, int, int, int, 0, 0> m0;
|
hb_hashmap_t<int, int, int, int, 0, 0> m0;
|
||||||
hb_hashmap_t<std::string, int, const std::string*, int, &invalid, 0> m1;
|
hb_hashmap_t<std::string, int, const std::string*, int, &invalid, 0> m1;
|
||||||
|
@ -127,7 +126,6 @@ main (int argc, char **argv)
|
||||||
m3.set (s, s);
|
m3.set (s, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue