#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
#include <cstdlib>
#include <cstring>
#include "partition_alloc/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/partition_alloc_base/compiler_specific.h"
#include "partition_alloc/partition_alloc_base/memory/page_size.h"
#include "partition_alloc/partition_alloc_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
#include <malloc.h>
#endif
#if PA_BUILDFLAG(IS_APPLE)
#include <malloc/malloc.h>
#endif
#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
PA_BUILDFLAG(USE_PARTITION_ALLOC)
namespace allocator_shim::internal {
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
PA_NOINLINE void FreeForTest(void* data) { … }
TEST(PartitionAllocAsMalloc, Mallinfo) { … }
#endif
#endif
TEST(PartitionAllocAsMalloc, Simple) { … }
TEST(PartitionAllocAsMalloc, MallocUnchecked) { … }
TEST(PartitionAllocAsMalloc, Calloc) { … }
TEST(PartitionAllocAsMalloc, Memalign) { … }
TEST(PartitionAllocAsMalloc, AlignedAlloc) { … }
TEST(PartitionAllocAsMalloc, AlignedRealloc) { … }
TEST(PartitionAllocAsMalloc, Realloc) { … }
TEST(PartitionAllocAsMalloc, Alignment) { … }
#if PA_BUILDFLAG(IS_APPLE) && PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
TEST(PartitionAllocAsMalloc, GoodSize) {
size_t size = 1;
int iterations = 0;
while (size < 256 * 1024) {
iterations++;
size = malloc_good_size(size + 1);
}
EXPECT_LT(iterations, 100);
}
#endif
}
#endif