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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: core/include/fxcrt/fx_memory.h
diff --git a/core/include/fxcrt/fx_memory.h b/core/include/fxcrt/fx_memory.h
index c607de2159fe47c6458d329097951a4ca83a448e..88e6873eddd590f62dea281cc8bb643862eaee85 100644
--- a/core/include/fxcrt/fx_memory.h
+++ b/core/include/fxcrt/fx_memory.h
@@ -49,6 +49,14 @@ inline void* FX_AllocOrDie2D(size_t w, size_t h, size_t member_size) {
return nullptr; // Suppress compiler warning.
}
+inline void* FX_AllocOrDie3D(size_t w, size_t h, size_t d, size_t member_size) {
+ if (w < std::numeric_limits<size_t>::max() / h) {
+ return FX_AllocOrDie2D(w * h, d, member_size);
+ }
+ FX_OutOfMemoryTerminate(); // Never returns.
+ return nullptr; // Suppress compiler warning.
+}
+
inline void* FX_ReallocOrDie(void* ptr,
size_t num_members,
size_t member_size) {
@@ -62,6 +70,7 @@ inline void* FX_ReallocOrDie(void* ptr,
// Never returns NULL.
#define FX_Alloc(type, size) (type*) FX_AllocOrDie(size, sizeof(type))
#define FX_Alloc2D(type, w, h) (type*) FX_AllocOrDie2D(w, h, sizeof(type))
+#define FX_Alloc3D(type, w, h, d) (type*) FX_AllocOrDie3D(w, h, d, sizeof(type))
#define FX_Realloc(type, ptr, size) \
(type*) FX_ReallocOrDie(ptr, size, sizeof(type))

Powered by Google App Engine
This is Rietveld 408576698