Snap for 11938003 from 2ec6d398ce to 24Q3-release

Change-Id: I1cfd1f6e47058b4c685cefdd859e0e2f7fbffa8e
This commit is contained in:
Android Build Coastguard Worker 2024-06-06 23:00:47 +00:00
commit 9c3fad326d

View file

@ -16,13 +16,14 @@
#include <new>
#include <errno.h>
#include <stdlib.h>
#include <async_safe/log.h>
__attribute__((weak)) const std::nothrow_t std::nothrow = {};
// We can't throw in bionic, so we go straight to the equivalent of
// std::terminate for these two instead.
void* operator new(std::size_t size) {
void* p = malloc(size);
if (p == nullptr) {
@ -30,7 +31,6 @@ void* operator new(std::size_t size) {
}
return p;
}
void* operator new[](std::size_t size) {
void* p = malloc(size);
if (p == nullptr) {
@ -39,26 +39,21 @@ void* operator new[](std::size_t size) {
return p;
}
void operator delete(void* ptr) throw() {
free(ptr);
}
void operator delete[](void* ptr) throw() {
free(ptr);
}
// These two are the "nothrow" variants, so we just return nullptr on failure.
void* operator new(std::size_t size, const std::nothrow_t&) {
return malloc(size);
}
void* operator new[](std::size_t size, const std::nothrow_t&) {
return malloc(size);
}
void operator delete(void* ptr, const std::nothrow_t&) throw() {
free(ptr);
}
// free() can't throw anyway (except on heap corruption, which is always fatal),
// so there's no difference between the regular and "nothrow" variants here.
void operator delete(void* p) noexcept { free(p); }
void operator delete[](void* p) noexcept { free(p); }
void operator delete(void* p, const std::nothrow_t&) noexcept { free(p); }
void operator delete[](void* p, const std::nothrow_t&) noexcept { free(p); }
void operator delete[](void* ptr, const std::nothrow_t&) throw() {
free(ptr);
}
// TODO: these can use free_sized() once we have it (http://b/284321795).
void operator delete(void* p, std::size_t) noexcept { free(p); }
void operator delete[](void* p, std::size_t) noexcept { free(p); }