Skip to content

Commit

Permalink
Fix the creation of fresh attribute indices in DefineAttribute
Browse files Browse the repository at this point in the history
This has already been fixed in the first overload that takes a `const T &value` argument, but is missing in the second overload that takes an array. Indices may currently be given out several times if attributes are deleted in between.
  • Loading branch information
franzpoeschel committed May 28, 2019
1 parent 421f29d commit 0039a98
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/adios2/core/IO.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ Attribute<T> &IO::DefineAttribute(const std::string &name, const T *array,
}

auto &attributeMap = GetAttributeMap<T>();
const unsigned int size = static_cast<unsigned int>(attributeMap.size());
const unsigned int newIndex =
attributeMap.empty() ? 0 : attributeMap.rbegin()->first + 1;

auto itAttributePair =
attributeMap.emplace(size, Attribute<T>(globalName, array, elements));
auto itAttributePair = attributeMap.emplace(
newIndex, Attribute<T>(globalName, array, elements));
m_Attributes.emplace(globalName,
std::make_pair(helper::GetType<T>(), size));
std::make_pair(helper::GetType<T>(), newIndex));

return itAttributePair.first->second;
}
Expand Down

0 comments on commit 0039a98

Please sign in to comment.