mirror of https://github.com/CGAL/cgal
Add reserve before the creation of a new attribute, copy of an old one: solve a bug for the index version of CMap/GMap when the underlying vector is reallocated
This commit is contained in:
parent
477f71b876
commit
72b356d309
|
|
@ -566,6 +566,15 @@ void test_split_attribute_functor_one_dart
|
||||||
Attribute_descriptor_i a1 = amap.template attribute<i>(adart);
|
Attribute_descriptor_i a1 = amap.template attribute<i>(adart);
|
||||||
if ( found_attributes.is_defined(a1) )
|
if ( found_attributes.is_defined(a1) )
|
||||||
{ // Here the attribute was already present in the hash_map
|
{ // Here the attribute was already present in the hash_map
|
||||||
|
|
||||||
|
// We need to call reserve for the cc with index case. Indeed, if the vector
|
||||||
|
// is reallocated, the reference returned by get_attribute<i>(a1) will be
|
||||||
|
// invalidated, and the copy will be wrong. Note that there is no overhead
|
||||||
|
// since the creation of the attribute need one allocation.
|
||||||
|
amap.template attributes<i>().reserve(amap.template attributes<i>().size()+1);
|
||||||
|
|
||||||
|
// Now we are sure that the creation of a new attribute will not imply
|
||||||
|
// a realloc.
|
||||||
Attribute_descriptor_i a2 = amap.template
|
Attribute_descriptor_i a2 = amap.template
|
||||||
create_attribute<i>(amap.template get_attribute<i>(a1));
|
create_attribute<i>(amap.template get_attribute<i>(a1));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,13 @@ void GMap_test_split_attribute_functor_one_dart
|
||||||
Attribute_descriptor_i a1 = amap.template attribute<i>(adart);
|
Attribute_descriptor_i a1 = amap.template attribute<i>(adart);
|
||||||
if ( found_attributes.is_defined(a1) )
|
if ( found_attributes.is_defined(a1) )
|
||||||
{ // Here the attribute was already present in the hash_map
|
{ // Here the attribute was already present in the hash_map
|
||||||
|
|
||||||
|
// We need to call reserve for the cc with index case. Indeed, if the vector
|
||||||
|
// is reallocated, the reference returned by get_attribute<i>(a1) will be
|
||||||
|
// invalidated, and the copy will be wrong. Note that there is no overhead
|
||||||
|
// since the creation of the attribute need one allocation.
|
||||||
|
amap.template attributes<i>().reserve(amap.template attributes<i>().size()+1);
|
||||||
|
|
||||||
Attribute_descriptor_i a2 = amap.template
|
Attribute_descriptor_i a2 = amap.template
|
||||||
create_attribute<i>(amap.template get_attribute<i>(a1));
|
create_attribute<i>(amap.template get_attribute<i>(a1));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue