mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-01-18 17:31:19 +01:00
Merge branch eigen:master into master
This commit is contained in:
@@ -91,6 +91,9 @@ namespace internal {
|
||||
EIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed() {
|
||||
eigen_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)");
|
||||
}
|
||||
EIGEN_DEVICE_FUNC inline void check_that_free_is_allowed() {
|
||||
eigen_assert(false && "heap deallocation is forbidden (EIGEN_NO_MALLOC is defined)");
|
||||
}
|
||||
#elif defined EIGEN_RUNTIME_NO_MALLOC
|
||||
EIGEN_DEVICE_FUNC inline bool is_malloc_allowed_impl(bool update, bool new_value = false) {
|
||||
EIGEN_MALLOC_CHECK_THREAD_LOCAL static bool value = true;
|
||||
@@ -101,10 +104,22 @@ EIGEN_DEVICE_FUNC inline bool is_malloc_allowed() { return is_malloc_allowed_imp
|
||||
EIGEN_DEVICE_FUNC inline bool set_is_malloc_allowed(bool new_value) { return is_malloc_allowed_impl(true, new_value); }
|
||||
EIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed() {
|
||||
eigen_assert(is_malloc_allowed() &&
|
||||
"heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and g_is_malloc_allowed is false)");
|
||||
"heap allocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and set_is_malloc_allowed is false)");
|
||||
}
|
||||
EIGEN_DEVICE_FUNC inline bool is_free_allowed_impl(bool update, bool new_value = false) {
|
||||
EIGEN_MALLOC_CHECK_THREAD_LOCAL static bool value = true;
|
||||
if (update == 1) value = new_value;
|
||||
return value;
|
||||
}
|
||||
EIGEN_DEVICE_FUNC inline bool is_free_allowed() { return is_free_allowed_impl(false); }
|
||||
EIGEN_DEVICE_FUNC inline bool set_is_free_allowed(bool new_value) { return is_free_allowed_impl(true, new_value); }
|
||||
EIGEN_DEVICE_FUNC inline void check_that_free_is_allowed() {
|
||||
eigen_assert(is_malloc_allowed() &&
|
||||
"heap deallocation is forbidden (EIGEN_RUNTIME_NO_MALLOC is defined and set_is_free_allowed is false)");
|
||||
}
|
||||
#else
|
||||
EIGEN_DEVICE_FUNC inline void check_that_malloc_is_allowed() {}
|
||||
EIGEN_DEVICE_FUNC inline void check_that_free_is_allowed() {}
|
||||
#endif
|
||||
|
||||
EIGEN_DEVICE_FUNC inline void throw_std_bad_alloc() {
|
||||
@@ -161,7 +176,7 @@ EIGEN_DEVICE_FUNC inline void handmade_aligned_free(void* ptr) {
|
||||
std::size_t offset = static_cast<std::size_t>(*(static_cast<uint8_t*>(ptr) - 1)) + 1;
|
||||
void* original = static_cast<void*>(static_cast<uint8_t*>(ptr) - offset);
|
||||
|
||||
check_that_malloc_is_allowed();
|
||||
check_that_free_is_allowed();
|
||||
EIGEN_USING_STD(free)
|
||||
free(original);
|
||||
}
|
||||
@@ -227,7 +242,7 @@ EIGEN_DEVICE_FUNC inline void aligned_free(void* ptr) {
|
||||
#if (EIGEN_DEFAULT_ALIGN_BYTES == 0) || EIGEN_MALLOC_ALREADY_ALIGNED
|
||||
|
||||
if (ptr != nullptr) {
|
||||
check_that_malloc_is_allowed();
|
||||
check_that_free_is_allowed();
|
||||
EIGEN_USING_STD(free)
|
||||
free(ptr);
|
||||
}
|
||||
@@ -299,7 +314,7 @@ EIGEN_DEVICE_FUNC inline void conditional_aligned_free(void* ptr) {
|
||||
template <>
|
||||
EIGEN_DEVICE_FUNC inline void conditional_aligned_free<false>(void* ptr) {
|
||||
if (ptr != nullptr) {
|
||||
check_that_malloc_is_allowed();
|
||||
check_that_free_is_allowed();
|
||||
EIGEN_USING_STD(free)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class SparseVector : public SparseCompressedBase<SparseVector<Scalar_, Options_,
|
||||
--p;
|
||||
}
|
||||
m_data.index(p + 1) = convert_index(i);
|
||||
m_data.value(p + 1) = 0;
|
||||
m_data.value(p + 1) = Scalar(0);
|
||||
return m_data.value(p + 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user