[NTOSKRNL:CC] Added Bounds Checked Array Class
This Bounds Checked array will be used for OBCB type
This commit is contained in:
parent
d825fe1dcb
commit
dac01f6510
@ -103,4 +103,44 @@ public:
|
||||
private:
|
||||
PEX_SPIN_LOCK m_SpinLock;
|
||||
KIRQL m_OldIrql;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Array {
|
||||
public:
|
||||
Array(T* data, size_t size) : data_(data), size_(size) {}
|
||||
|
||||
T& operator[](size_t index) {
|
||||
checkBounds(index);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
const T& operator[](size_t index) const {
|
||||
checkBounds(index);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
T& at(size_t index) {
|
||||
checkBounds(index);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
const T& at(size_t index) const {
|
||||
checkBounds(index);
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
private:
|
||||
T* data_;
|
||||
size_t size_;
|
||||
|
||||
void checkBounds(size_t index) const {
|
||||
if (index >= size_) {
|
||||
ExRaiseStatus(STATUS_ARRAY_BOUNDS_EXCEEDED);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user