summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp13
-rw-r--r--core/fxcrt/cfx_string_data_template.h5
-rw-r--r--core/fxcrt/fx_basic_memmgr.cpp3
-rw-r--r--core/fxcrt/fx_memory.h5
4 files changed, 21 insertions, 5 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 331cec3813..fdf31243b7 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -14,13 +14,20 @@
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
-class CPDF_PageContentGeneratorTest : public testing::Test {
+class CPDF_PageContentGeneratorTest : public pdfium::FPDF_Test {
protected:
- void SetUp() override { CPDF_ModuleMgr::Get()->InitPageModule(); }
+ void SetUp() override {
+ FPDF_Test::SetUp();
+ CPDF_ModuleMgr::Get()->InitPageModule();
+ }
- void TearDown() override { CPDF_ModuleMgr::Destroy(); }
+ void TearDown() override {
+ CPDF_ModuleMgr::Destroy();
+ FPDF_Test::TearDown();
+ }
void TestProcessPath(CPDF_PageContentGenerator* pGen,
CFX_ByteTextBuf* buf,
diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/cfx_string_data_template.h
index 2e87a811a5..33013fde33 100644
--- a/core/fxcrt/cfx_string_data_template.h
+++ b/core/fxcrt/cfx_string_data_template.h
@@ -35,7 +35,8 @@ class CFX_StringDataTemplate {
int usableLen = (totalSize - overhead) / sizeof(CharType);
ASSERT(usableLen >= nLen);
- void* pData = FX_Alloc(uint8_t, totalSize);
+ void* pData = pdfium::base::PartitionAllocGeneric(
+ gStringPartitionAllocator.root(), totalSize, "CFX_StringDataTemplate");
return new (pData) CFX_StringDataTemplate(nLen, usableLen);
}
@@ -54,7 +55,7 @@ class CFX_StringDataTemplate {
void Retain() { ++m_nRefs; }
void Release() {
if (--m_nRefs <= 0)
- FX_Free(this);
+ pdfium::base::PartitionFree(this);
}
bool CanOperateInPlace(FX_STRSIZE nTotalLen) const {
diff --git a/core/fxcrt/fx_basic_memmgr.cpp b/core/fxcrt/fx_basic_memmgr.cpp
index 927b994b5f..06568c04ad 100644
--- a/core/fxcrt/fx_basic_memmgr.cpp
+++ b/core/fxcrt/fx_basic_memmgr.cpp
@@ -8,6 +8,9 @@
#include "core/fxcrt/fx_memory.h"
+pdfium::base::PartitionAllocatorGeneric gArrayBufferPartitionAllocator;
+pdfium::base::PartitionAllocatorGeneric gStringPartitionAllocator;
+
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 0ad28ce896..c4d619efab 100644
--- a/core/fxcrt/fx_memory.h
+++ b/core/fxcrt/fx_memory.h
@@ -26,6 +26,11 @@ void FXMEM_DefaultFree(void* pointer, int flags);
#include <memory>
#include <new>
+#include "third_party/base/allocator/partition_allocator/partition_alloc.h"
+
+extern pdfium::base::PartitionAllocatorGeneric gArrayBufferPartitionAllocator;
+extern pdfium::base::PartitionAllocatorGeneric gStringPartitionAllocator;
+
NEVER_INLINE void FX_OutOfMemoryTerminate();
inline void* FX_SafeRealloc(void* ptr, size_t num_members, size_t member_size) {