From 2b797295d6851b3189bcb38c5994074f36453865 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Thu, 6 Apr 2017 14:45:39 -0700 Subject: Fix unit tests to initialize PartitionAlloc. Tests need to be subclasses of FPDF_Test. BUG=pdfium:700 Change-Id: I317ec2c49567e58cb57c6222e387574226f594b3 Reviewed-on: https://pdfium-review.googlesource.com/3890 Reviewed-by: Tom Sepez Commit-Queue: Chris Palmer --- core/fxcrt/fx_basic_memmgr.cpp | 10 ++++++++++ core/fxcrt/fx_memory.h | 1 + 2 files changed, 11 insertions(+) (limited to 'core') diff --git a/core/fxcrt/fx_basic_memmgr.cpp b/core/fxcrt/fx_basic_memmgr.cpp index 06568c04ad..f3aaa3678d 100644 --- a/core/fxcrt/fx_basic_memmgr.cpp +++ b/core/fxcrt/fx_basic_memmgr.cpp @@ -11,6 +11,16 @@ pdfium::base::PartitionAllocatorGeneric gArrayBufferPartitionAllocator; pdfium::base::PartitionAllocatorGeneric gStringPartitionAllocator; +void FXMEM_InitalizePartitionAlloc() { + static bool s_gPartitionAllocatorsInitialized = false; + if (!s_gPartitionAllocatorsInitialized) { + pdfium::base::PartitionAllocGlobalInit(FX_OutOfMemoryTerminate); + gArrayBufferPartitionAllocator.init(); + gStringPartitionAllocator.init(); + s_gPartitionAllocatorsInitialized = true; + } +} + void* FXMEM_DefaultAlloc(size_t byte_size, int flags) { return (void*)malloc(byte_size); } diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h index c4d619efab..eb369d7d6c 100644 --- a/core/fxcrt/fx_memory.h +++ b/core/fxcrt/fx_memory.h @@ -31,6 +31,7 @@ void FXMEM_DefaultFree(void* pointer, int flags); extern pdfium::base::PartitionAllocatorGeneric gArrayBufferPartitionAllocator; extern pdfium::base::PartitionAllocatorGeneric gStringPartitionAllocator; +void FXMEM_InitalizePartitionAlloc(); NEVER_INLINE void FX_OutOfMemoryTerminate(); inline void* FX_SafeRealloc(void* ptr, size_t num_members, size_t member_size) { -- cgit v1.2.3