diff options
author | Tomasz Wasilczyk <twasilczyk@google.com> | 2024-01-12 08:32:32 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-12 08:32:32 +0000 |
commit | 7de3d7cd2c447259ab37e2da7f16dd5fdb3cf86c (patch) | |
tree | 808a4747a30f4f3c3d5d877ba1dcbc8f017b0732 | |
parent | 6f6f0a4b9f45dbc0b4d67c8b602c4062d21f91d9 (diff) | |
parent | a2c927e84d3cb73fed3056bf419346b2c0969eb0 (diff) | |
download | libbrillo-7de3d7cd2c447259ab37e2da7f16dd5fdb3cf86c.tar.gz |
Don't use std::allocator::pointer am: 1fa3355b80 am: 5922f67e96 am: a2c927e84d
Original change: https://android-review.googlesource.com/c/platform/external/libbrillo/+/2906695
Change-Id: Id6455c8efac0db864ebc68f9832fb58ed5e1c4e6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | brillo/secure_allocator.h | 11 | ||||
-rw-r--r-- | brillo/secure_blob_test.cc | 3 |
2 files changed, 6 insertions, 8 deletions
diff --git a/brillo/secure_allocator.h b/brillo/secure_allocator.h index de0b348..ad0036b 100644 --- a/brillo/secure_allocator.h +++ b/brillo/secure_allocator.h @@ -53,7 +53,6 @@ namespace brillo { template <typename T> class BRILLO_PRIVATE SecureAllocator : public std::allocator<T> { public: - using typename std::allocator<T>::pointer; using typename std::allocator<T>::size_type; using typename std::allocator<T>::value_type; @@ -75,8 +74,8 @@ class BRILLO_PRIVATE SecureAllocator : public std::allocator<T> { size_type max_size() const { return max_size_; } // Allocation: allocate ceil(size/pagesize) for holding the data. - pointer allocate(size_type n, pointer hint = nullptr) { - pointer buffer = nullptr; + value_type* allocate(size_type n, value_type* hint = nullptr) { + value_type* buffer = nullptr; // Check if n can be theoretically allocated. CHECK_LT(n, max_size()); @@ -97,7 +96,7 @@ class BRILLO_PRIVATE SecureAllocator : public std::allocator<T> { size_type buffer_size = CalculatePageAlignedBufferSize(n); // Memory locking granularity is per-page: mmap ceil(size/page size) pages. - buffer = reinterpret_cast<pointer>( + buffer = reinterpret_cast<value_type*>( mmap(nullptr, buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)); if (buffer == MAP_FAILED) @@ -155,7 +154,7 @@ class BRILLO_PRIVATE SecureAllocator : public std::allocator<T> { clear_contents(p, sizeof(U)); } - virtual void deallocate(pointer p, size_type n) { + virtual void deallocate(value_type* p, size_type n) { // Check if n can be theoretically deallocated. CHECK_LT(n, max_size()); @@ -182,7 +181,7 @@ class BRILLO_PRIVATE SecureAllocator : public std::allocator<T> { #endif // Zero-out all bytes in the allocated buffer. - virtual void __attribute_no_opt clear_contents(pointer v, size_type n) { + virtual void __attribute_no_opt clear_contents(value_type* v, size_type n) { if (!v) return; memset(v, 0, n); diff --git a/brillo/secure_blob_test.cc b/brillo/secure_blob_test.cc index 871c79c..8a4a1e8 100644 --- a/brillo/secure_blob_test.cc +++ b/brillo/secure_blob_test.cc @@ -232,14 +232,13 @@ TEST_F(SecureBlobTest, HexStringToSecureBlob) { template <typename T> class TestSecureAllocator : public SecureAllocator<T> { public: - using typename SecureAllocator<T>::pointer; using typename SecureAllocator<T>::size_type; using typename SecureAllocator<T>::value_type; int GetErasedCount() { return erased_count; } protected: - void clear_contents(pointer p, size_type n) override { + void clear_contents(value_type* p, size_type n) override { SecureAllocator<T>::clear_contents(p, n); unsigned char *v = reinterpret_cast<unsigned char*>(p); for (int i = 0; i < n; i++) { |