emptyTrash();
Debug("gc") << "done emptying trash for " << this << std::endl;
- for(Element* i = d_first; i != NULL;) {
+ for(typename table_type::iterator i = d_map.begin();
+ i != d_map.end();
+ ++i) {
// mark it as being a destruction (short-circuit restore())
- Element* thisOne = i;
- i = i->next();
- thisOne->d_map = NULL;
- if(!thisOne->d_noTrash) {
- thisOne->deleteSelf();
+ (*i).second->d_map = NULL;
+ if(!(*i).second->d_noTrash) {
+ (*i).second->deleteSelf();
}
}
d_map.clear();
deleteFromTable(d_ptrs, nv);
// FIXME CD-bools in optimized table
- for(unsigned id = 0; id < attr::LastAttributeId<bool, true>::s_id; ++id) {
- d_cdbools.obliterate(std::make_pair(id, nv));
- }
- for(unsigned id = 0; id < attr::LastAttributeId<uint64_t, true>::s_id; ++id) {
- d_cdints.obliterate(std::make_pair(id, nv));
- }
- for(unsigned id = 0; id < attr::LastAttributeId<TNode, true>::s_id; ++id) {
- d_cdtnodes.obliterate(std::make_pair(id, nv));
- }
- for(unsigned id = 0; id < attr::LastAttributeId<TNode, true>::s_id; ++id) {
- d_cdnodes.obliterate(std::make_pair(id, nv));
- }
- for(unsigned id = 0; id < attr::LastAttributeId<std::string, true>::s_id; ++id) {
- d_cdstrings.obliterate(std::make_pair(id, nv));
- }
- for(unsigned id = 0; id < attr::LastAttributeId<void*, true>::s_id; ++id) {
- d_cdptrs.obliterate(std::make_pair(id, nv));
- }
+ deleteFromTable(d_cdbools, nv);
+ deleteFromTable(d_cdints, nv);
+ deleteFromTable(d_cdtnodes, nv);
+ deleteFromTable(d_cdnodes, nv);
+ deleteFromTable(d_cdstrings, nv);
+ deleteFromTable(d_cdptrs, nv);
}
void AttributeManager::deleteAllAttributes() {
template <class T>
void deleteFromTable(AttrHash<T>& table, NodeValue* nv);
+ template <class T>
+ void deleteFromTable(CDAttrHash<T>& table, NodeValue* nv);
+
template <class T>
void deleteAllFromTable(AttrHash<T>& table);
}
}
+/**
+ * Obliterate a NodeValue from a (context-dependent) attribute table.
+ */
+template <class T>
+inline void AttributeManager::deleteFromTable(CDAttrHash<T>& table,
+ NodeValue* nv) {
+ for(unsigned id = 0; id < attr::LastAttributeId<T, true>::s_id; ++id) {
+ table.obliterate(std::make_pair(id, nv));
+ }
+}
+
/**
* Remove all attributes from the table calling the cleanup function if one is defined.
*/