From 9ccb6024a0d0af7e2484b67efa036c0d790c5108 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sun, 10 Oct 2021 22:47:02 -0700 Subject: [PATCH] [NFC][sanitizer] Add a few consts --- compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h | 4 ++-- compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h index 38d2a7d..e736796 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -198,7 +198,7 @@ class SizeClassAllocator32 { return GetSizeClass(p) != 0; } - uptr GetSizeClass(const void *p) { + uptr GetSizeClass(const void *p) const { return possible_regions[ComputeRegionId(reinterpret_cast(p))]; } @@ -251,7 +251,7 @@ class SizeClassAllocator32 { // Iterate over all existing chunks. // The allocator must be locked when calling this function. - void ForEachChunk(ForEachChunkCallback callback, void *arg) { + void ForEachChunk(ForEachChunkCallback callback, void *arg) const { for (uptr region = 0; region < kNumPossibleRegions; region++) if (possible_regions[region]) { uptr chunk_size = ClassIdToSize(possible_regions[region]); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h index 3040a1f..ab9e0eb 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h @@ -41,7 +41,7 @@ class FlatMap { CHECK_EQ(0U, map_[idx]); map_[idx] = val; } - u8 operator[](uptr idx) { + u8 operator[](uptr idx) const { CHECK_LT(idx, kSize); // FIXME: CHECK may be too expensive here. return map_[idx]; -- 2.7.4