| 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))
|
|
|
|
|