]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Revert "Hack around invalid iterator problems"
authorPetr Machata <pmachata@redhat.com>
Thu, 20 Aug 2009 12:58:26 +0000 (14:58 +0200)
committerPetr Machata <pmachata@redhat.com>
Thu, 20 Aug 2009 12:58:26 +0000 (14:58 +0200)
... in preparation to merge

libdw/c++/dwarf_output
libdw/c++/subr.hh

index 66c736dcd4c3316d2a3799103b5c3d6b3810a45e..30e5fd68348499c85f10fb9fec58e2ba1b97491b 100644 (file)
@@ -430,17 +430,6 @@ namespace elfutils
        inline children_type (const input &other, copier &c)
          : _base (), _m_hash (0)
        {
-         /* XXX hack.  We use vector iterators as die references.
-            push_back potentially invalidates these iterators.  Work
-            around that by reserving vector big enough to hold all
-            the children, so that realloc & invalidation of these
-            iterators doesn't occur.  */
-         size_t count = 0;
-         for (typename input::const_iterator in = other.begin ();
-              in != other.end (); ++in)
-           ++count;
-         reserve (count);
-
          typename input::const_iterator in = other.begin ();
          bool has_sibling = in != other.end ();
          while (has_sibling)
@@ -875,28 +864,12 @@ namespace elfutils
     }
 
     // Set of children lists.
-    //subr::identity_set<children_type> _m_broods;
-    template<typename T>
-    struct is2 : public std::equal_to<T *>
-    {
-      bool operator () (const T *a, const T *b) const
-      {
-       return a->is (*b);
-      }
-    };
-    std::tr1::unordered_set<children_type *, children_type::hasher, is2<children_type> >
-       _m_broods;
+    subr::identity_set<children_type> _m_broods;
 
     template<typename input, typename copier_type>
     inline const children_type *add_children (const input &x, copier_type &c)
     {
-      /* XXX another problem: We probably construct our references
-        from iterators pointing to the temporary vector.  When that
-        gets copied over to _m_broods, the original vector is
-        destroyed and iterators are left hanging there.  Work around
-        that by allocating on heap and bending a bunch of stuff to
-        work with pointers too.  Ugly & leaks, but works for now.  */
-      return *_m_broods.insert (new children_type (x, c)).first;
+      return &*_m_broods.insert (children_type (x, c)).first;
     }
 
     struct die_info
index 33dd8f0f3532060aeb5f6a8539780f3175a48231..ca6a709e5f45a898ae2b1811714aca0a6c97e28d 100644 (file)
@@ -138,10 +138,6 @@ namespace elfutils
       {
        return v._m_hash;
       }
-      size_t operator () (const T *v) const
-      {
-       return v->_m_hash;
-      }
     };
 
     template<typename string>