vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / util / RangeList.h
blobb37fc1ba50bb741573a365cb23bcf56cb540f14a
1 /*
2 * Copyright 2013, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef RANGE_LIST_H
6 #define RANGE_LIST_H
9 #include <ObjectList.h>
10 #include <SupportDefs.h>
13 struct Range {
14 int32 lowerBound;
15 int32 upperBound;
17 Range()
19 lowerBound(-1),
20 upperBound(-1)
24 Range(int32 lowValue, int32 highValue)
26 lowerBound(lowValue),
27 upperBound(highValue)
33 class RangeList : private BObjectList<Range>
35 public:
36 RangeList();
37 virtual ~RangeList();
40 status_t AddRange(int32 lowValue, int32 highValue);
41 status_t AddRange(const Range& range);
43 void RemoveRangeAt(int32 index);
45 int32 CountRanges() const;
46 const Range* RangeAt(int32 index) const;
48 bool Contains(int32 value) const;
50 private:
51 void _CollapseOverlappingRanges(int32 startIndex,
52 int32 highValue);
55 #endif // RANGE_LIST_H