Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: core/include/fxcrt/fx_memory.h

Issue 1326953006: Remove CJBig2_Object, CJBig2_Module, and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_INCLUDE_FXCRT_FX_MEMORY_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_MEMORY_H_
8 #define CORE_INCLUDE_FXCRT_FX_MEMORY_H_ 8 #define CORE_INCLUDE_FXCRT_FX_MEMORY_H_
9 9
10 #include "fx_system.h" 10 #include "fx_system.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 inline void* FX_AllocOrDie2D(size_t w, size_t h, size_t member_size) { 44 inline void* FX_AllocOrDie2D(size_t w, size_t h, size_t member_size) {
45 if (w < std::numeric_limits<size_t>::max() / h) { 45 if (w < std::numeric_limits<size_t>::max() / h) {
46 return FX_AllocOrDie(w * h, member_size); 46 return FX_AllocOrDie(w * h, member_size);
47 } 47 }
48 FX_OutOfMemoryTerminate(); // Never returns. 48 FX_OutOfMemoryTerminate(); // Never returns.
49 return nullptr; // Suppress compiler warning. 49 return nullptr; // Suppress compiler warning.
50 } 50 }
51 51
52 inline void* FX_AllocOrDie3D(size_t w, size_t h, size_t d, size_t member_size) {
53 if (w < std::numeric_limits<size_t>::max() / h) {
54 return FX_AllocOrDie2D(w * h, d, member_size);
55 }
56 FX_OutOfMemoryTerminate(); // Never returns.
57 return nullptr; // Suppress compiler warning.
58 }
59
52 inline void* FX_ReallocOrDie(void* ptr, 60 inline void* FX_ReallocOrDie(void* ptr,
53 size_t num_members, 61 size_t num_members,
54 size_t member_size) { 62 size_t member_size) {
55 if (void* result = FX_SafeRealloc(ptr, num_members, member_size)) { 63 if (void* result = FX_SafeRealloc(ptr, num_members, member_size)) {
56 return result; 64 return result;
57 } 65 }
58 FX_OutOfMemoryTerminate(); // Never returns. 66 FX_OutOfMemoryTerminate(); // Never returns.
59 return nullptr; // Suppress compiler warning. 67 return nullptr; // Suppress compiler warning.
60 } 68 }
61 69
62 // Never returns NULL. 70 // Never returns NULL.
63 #define FX_Alloc(type, size) (type*) FX_AllocOrDie(size, sizeof(type)) 71 #define FX_Alloc(type, size) (type*) FX_AllocOrDie(size, sizeof(type))
64 #define FX_Alloc2D(type, w, h) (type*) FX_AllocOrDie2D(w, h, sizeof(type)) 72 #define FX_Alloc2D(type, w, h) (type*) FX_AllocOrDie2D(w, h, sizeof(type))
73 #define FX_Alloc3D(type, w, h, d) (type*) FX_AllocOrDie3D(w, h, d, sizeof(type))
65 #define FX_Realloc(type, ptr, size) \ 74 #define FX_Realloc(type, ptr, size) \
66 (type*) FX_ReallocOrDie(ptr, size, sizeof(type)) 75 (type*) FX_ReallocOrDie(ptr, size, sizeof(type))
67 76
68 // May return NULL. 77 // May return NULL.
69 #define FX_TryAlloc(type, size) (type*) calloc(size, sizeof(type)) 78 #define FX_TryAlloc(type, size) (type*) calloc(size, sizeof(type))
70 #define FX_TryRealloc(type, ptr, size) \ 79 #define FX_TryRealloc(type, ptr, size) \
71 (type*) FX_SafeRealloc(ptr, size, sizeof(type)) 80 (type*) FX_SafeRealloc(ptr, size, sizeof(type))
72 81
73 #define FX_Free(ptr) free(ptr) 82 #define FX_Free(ptr) free(ptr)
74 83
(...skipping 26 matching lines...) Expand all
101 void FreeAll(); 110 void FreeAll();
102 111
103 private: 112 private:
104 size_t m_TrunkSize; 113 size_t m_TrunkSize;
105 114
106 void* m_pFirstTrunk; 115 void* m_pFirstTrunk;
107 }; 116 };
108 #endif // __cplusplus 117 #endif // __cplusplus
109 118
110 #endif // CORE_INCLUDE_FXCRT_FX_MEMORY_H_ 119 #endif // CORE_INCLUDE_FXCRT_FX_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698