aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-12-16 15:44:48 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-12-16 15:44:48 +0000
commit2110cca4313ebb902ca1f4f6ff0c389f743e60fc (patch)
tree1529ff2ea26d63e6a4ed6365e0a5cf784a5085bd /Eigen
parent38b83b4157a19ed913b0c5f884629930348cc716 (diff)
actually honor EIGEN_STACK_ALLOCATION.
Can set it to 0 to disable stack alloc which guarantees that bad alloc throws exceptions if they are enabled.
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/util/Macros.h4
-rw-r--r--Eigen/src/Core/util/Memory.h9
2 files changed, 9 insertions, 4 deletions
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
index c95030524..274d59057 100644
--- a/Eigen/src/Core/util/Macros.h
+++ b/Eigen/src/Core/util/Macros.h
@@ -116,6 +116,10 @@ using Eigen::ei_cos;
#define EIGEN_RESTRICT __restrict
+#ifndef EIGEN_STACK_ALLOCATION_LIMIT
+#define EIGEN_STACK_ALLOCATION_LIMIT 16000000
+#endif
+
#ifndef EIGEN_DEFAULT_IO_FORMAT
#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
#endif
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 63f9a07fc..b09e11bd4 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -143,11 +143,12 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
* \endcode
*/
#ifdef __linux__
-# define ei_alloc_stack(TYPE,SIZE) ((sizeof(TYPE)*(SIZE)>16000000) ? new TYPE[SIZE] : (TYPE*)alloca(sizeof(TYPE)*(SIZE)))
-# define ei_free_stack(PTR,TYPE,SIZE) if (sizeof(TYPE)*SIZE>16000000) delete[] PTR
+ #define ei_alloc_stack(TYPE,SIZE) ((sizeof(TYPE)*(SIZE)>EIGEN_STACK_ALLOCATION_LIMIT) ? \
+ new TYPE[SIZE] : (TYPE*)alloca(sizeof(TYPE)*(SIZE)))
+ #define ei_free_stack(PTR,TYPE,SIZE) if (sizeof(TYPE)*SIZE>EIGEN_STACK_ALLOCATION_LIMIT) delete[] PTR
#else
-# define ei_alloc_stack(TYPE,SIZE) new TYPE[SIZE]
-# define ei_free_stack(PTR,TYPE,SIZE) delete[] PTR
+ #define ei_alloc_stack(TYPE,SIZE) new TYPE[SIZE]
+ #define ei_free_stack(PTR,TYPE,SIZE) delete[] PTR
#endif
/** \class WithAlignedOperatorNew