Merge "Add a ZeroingAllocator::rebind<Other> for Other==char" into main am: c2b3fefa01

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2673490

Change-Id: Ib95f19d558139205647dfa086b92c966bcdbc7ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ryan Prichard 2023-07-26 00:10:17 +00:00 committed by Automerger Merge Worker
commit 727ef62350

View file

@ -19,6 +19,7 @@
#include <string.h>
#include <memory>
#include <type_traits>
#include <vector>
namespace android {
@ -31,6 +32,12 @@ class ZeroingAllocator : public std::allocator<char> {
memset_explicit(p, 0, n);
std::allocator<char>::deallocate(p, n);
}
template <class Other>
struct rebind {
static_assert(std::is_same_v<char, Other>, "ZeroingAllocator is only defined for char");
using other = ZeroingAllocator;
};
};
// Char vector that zeroes memory when deallocating.