diff options
Diffstat (limited to 'lib/sanitizer_common/sanitizer_list.h')
| -rw-r--r-- | lib/sanitizer_common/sanitizer_list.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_list.h b/lib/sanitizer_common/sanitizer_list.h index f61d28f3d900..a47bc7d45e3e 100644 --- a/lib/sanitizer_common/sanitizer_list.h +++ b/lib/sanitizer_common/sanitizer_list.h @@ -26,6 +26,8 @@ namespace __sanitizer { // non-zero-initialized objects before using. template<class Item> struct IntrusiveList { + friend class Iterator; + void clear() { first_ = last_ = 0; size_ = 0; @@ -113,6 +115,21 @@ struct IntrusiveList { } } + class Iterator { + public: + explicit Iterator(IntrusiveList<Item> *list) + : list_(list), current_(list->first_) { } + Item *next() { + Item *ret = current_; + if (current_) current_ = current_->next; + return ret; + } + bool hasNext() const { return current_ != 0; } + private: + IntrusiveList<Item> *list_; + Item *current_; + }; + // private, don't use directly. uptr size_; Item *first_; |
