summaryrefslogtreecommitdiff
path: root/core/templates/paged_allocator.h
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-05-22 23:22:48 +0200
committerGitHub <noreply@github.com>2021-05-22 23:22:48 +0200
commitde4c17f716acf0efe484a3f553ebd817fd4c256e (patch)
treea23662879adedea7e4a967a06d4ace2b63c6d3e3 /core/templates/paged_allocator.h
parent234a101eb377d95a7ae11d4830cfdb115fbd0599 (diff)
parentd1bc88d426b3751a37beb9c81513ccd16c7e2860 (diff)
Merge pull request #48916 from mortarroad/master-convex-hull-ported
Replace QuickHull with Bullet's convex hull computer.
Diffstat (limited to 'core/templates/paged_allocator.h')
-rw-r--r--core/templates/paged_allocator.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/templates/paged_allocator.h b/core/templates/paged_allocator.h
index 7002034710..481289309f 100644
--- a/core/templates/paged_allocator.h
+++ b/core/templates/paged_allocator.h
@@ -35,6 +35,8 @@
#include "core/os/spin_lock.h"
#include "core/typedefs.h"
+#include <type_traits>
+
template <class T, bool thread_safe = false>
class PagedAllocator {
T **page_pool = nullptr;
@@ -89,8 +91,10 @@ public:
allocs_available++;
}
- void reset() {
- ERR_FAIL_COND(allocs_available < pages_allocated * page_size);
+ void reset(bool p_allow_unfreed = false) {
+ if (!p_allow_unfreed || !std::is_trivially_destructible<T>::value) {
+ ERR_FAIL_COND(allocs_available < pages_allocated * page_size);
+ }
if (pages_allocated) {
for (uint32_t i = 0; i < pages_allocated; i++) {
memfree(page_pool[i]);