aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Wasilczyk <twasilczyk@google.com>2024-01-12 07:29:21 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-12 07:29:21 +0000
commita2c927e84d3cb73fed3056bf419346b2c0969eb0 (patch)
tree808a4747a30f4f3c3d5d877ba1dcbc8f017b0732
parent32a9a287af2d1a759c974f4e922ccb28c89f1d59 (diff)
parent5922f67e96b47de6a2dfa378073d1eed74693b54 (diff)
downloadlibbrillo-a2c927e84d3cb73fed3056bf419346b2c0969eb0.tar.gz
Don't use std::allocator::pointer am: 1fa3355b80 am: 5922f67e96
Original change: https://android-review.googlesource.com/c/platform/external/libbrillo/+/2906695 Change-Id: I60d0fa8cda138c71ed9a3f831fb38ec600e2c680 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--brillo/secure_allocator.h11
-rw-r--r--brillo/secure_blob_test.cc3
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++) {