Provide malloc-free sentinels for the SparseBitVector internals.

llvm-svn: 164823
This commit is contained in:
Benjamin Kramer 2012-09-28 15:36:41 +00:00
parent 91c06da5f1
commit c7d6a2df38
1 changed files with 16 additions and 0 deletions

View File

@ -262,6 +262,22 @@ public:
}
};
template <unsigned ElementSize>
struct ilist_traits<SparseBitVectorElement<ElementSize> >
: public ilist_default_traits<SparseBitVectorElement<ElementSize> > {
typedef SparseBitVectorElement<ElementSize> Element;
Element *createSentinel() const { return static_cast<Element *>(&Sentinel); }
static void destroySentinel(Element *) {}
Element *provideInitialHead() const { return createSentinel(); }
Element *ensureHead(Element *) const { return createSentinel(); }
static void noteHead(Element *, Element *) {}
private:
mutable ilist_half_node<Element> Sentinel;
};
template <unsigned ElementSize = 128>
class SparseBitVector {
typedef ilist<SparseBitVectorElement<ElementSize> > ElementList;