summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_memory.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-25 10:37:47 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-25 17:57:49 +0000
commita9deea931ed7c7526bb32e30c54d91763f8026e0 (patch)
tree32833dca01bfdf09cb5a8618bf992dacb7024c7c /core/fxcrt/fx_memory.cpp
parent6302288dec6111120749754ba8ec2d249b63404b (diff)
downloadpdfium-a9deea931ed7c7526bb32e30c54d91763f8026e0.tar.xz
Rename fx_basic_memmgr.cpp to fx_memory.cpp to match .h naming
Change-Id: I769d7f2c52b0a0db36be6145bfb626c126a58be9 Reviewed-on: https://pdfium-review.googlesource.com/4480 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_memory.cpp')
-rw-r--r--core/fxcrt/fx_memory.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/core/fxcrt/fx_memory.cpp b/core/fxcrt/fx_memory.cpp
new file mode 100644
index 0000000000..2807139aa2
--- /dev/null
+++ b/core/fxcrt/fx_memory.cpp
@@ -0,0 +1,46 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxcrt/fx_memory.h"
+
+#include <stdlib.h> // For abort().
+
+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);
+}
+
+void* FXMEM_DefaultCalloc(size_t num_elems, size_t byte_size) {
+ return calloc(num_elems, byte_size);
+}
+
+void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags) {
+ return realloc(pointer, new_size);
+}
+
+void FXMEM_DefaultFree(void* pointer, int flags) {
+ free(pointer);
+}
+
+NEVER_INLINE void FX_OutOfMemoryTerminate() {
+ // Termimate cleanly if we can, else crash at a specific address (0xbd).
+ abort();
+#ifndef _WIN32
+ reinterpret_cast<void (*)()>(0xbd)();
+#endif
+}