aboutsummaryrefslogtreecommitdiff
path: root/webrtc/system_wrappers/include/aligned_array.h
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/system_wrappers/include/aligned_array.h')
-rw-r--r--webrtc/system_wrappers/include/aligned_array.h34
1 files changed, 16 insertions, 18 deletions
diff --git a/webrtc/system_wrappers/include/aligned_array.h b/webrtc/system_wrappers/include/aligned_array.h
index a3a5911e36..a2ffe99c14 100644
--- a/webrtc/system_wrappers/include/aligned_array.h
+++ b/webrtc/system_wrappers/include/aligned_array.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_
-#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_
+#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_
+#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_
#include "webrtc/base/checks.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
@@ -20,21 +20,20 @@ namespace webrtc {
// aligned to the given byte alignment.
template<typename T> class AlignedArray {
public:
- AlignedArray(int rows, size_t cols, int alignment)
+ AlignedArray(size_t rows, size_t cols, size_t alignment)
: rows_(rows),
- cols_(cols),
- alignment_(alignment) {
- RTC_CHECK_GT(alignment_, 0);
+ cols_(cols) {
+ RTC_CHECK_GT(alignment, 0u);
head_row_ = static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_),
- alignment_));
- for (int i = 0; i < rows_; ++i) {
+ alignment));
+ for (size_t i = 0; i < rows_; ++i) {
head_row_[i] = static_cast<T*>(AlignedMalloc(cols_ * sizeof(**head_row_),
- alignment_));
+ alignment));
}
}
~AlignedArray() {
- for (int i = 0; i < rows_; ++i) {
+ for (size_t i = 0; i < rows_; ++i) {
AlignedFree(head_row_[i]);
}
AlignedFree(head_row_);
@@ -48,27 +47,27 @@ template<typename T> class AlignedArray {
return head_row_;
}
- T* Row(int row) {
+ T* Row(size_t row) {
RTC_CHECK_LE(row, rows_);
return head_row_[row];
}
- const T* Row(int row) const {
+ const T* Row(size_t row) const {
RTC_CHECK_LE(row, rows_);
return head_row_[row];
}
- T& At(int row, size_t col) {
+ T& At(size_t row, size_t col) {
RTC_CHECK_LE(col, cols_);
return Row(row)[col];
}
- const T& At(int row, size_t col) const {
+ const T& At(size_t row, size_t col) const {
RTC_CHECK_LE(col, cols_);
return Row(row)[col];
}
- int rows() const {
+ size_t rows() const {
return rows_;
}
@@ -77,12 +76,11 @@ template<typename T> class AlignedArray {
}
private:
- int rows_;
+ size_t rows_;
size_t cols_;
- int alignment_;
T** head_row_;
};
} // namespace webrtc
-#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_ALIGNED_ARRAY_
+#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_ALIGNED_ARRAY_