summaryrefslogtreecommitdiff
path: root/src/3rdparty/squirrel
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-04-15 19:49:30 +0200
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-05-11 15:34:33 +0200
commit140a96b3a0fa652b66c701ac941cebc17ff24622 (patch)
treeec64deb3e7ef5032dc18991cf5bb0d4eede52fb5 /src/3rdparty/squirrel
parentc9fe6e7b8fde3a23f6aab3b55fd8cca639d49696 (diff)
downloadopenttd-140a96b3a0fa652b66c701ac941cebc17ff24622.tar.xz
Change: Limit memory allocations for each Squirrel instance
This can avoid out-of-memory situations due to single scripts using up the entire address space. Instead, scripts that go above the maximum are killed. The maximum is default 1 GB per script, but can be configured by a setting.
Diffstat (limited to 'src/3rdparty/squirrel')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqmem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqmem.cpp b/src/3rdparty/squirrel/squirrel/sqmem.cpp
index 5c1b3966a..f4fa6309e 100644
--- a/src/3rdparty/squirrel/squirrel/sqmem.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqmem.cpp
@@ -9,8 +9,10 @@
#include "../../../core/alloc_func.hpp"
#include "../../../safeguards.h"
-void *sq_vm_malloc(SQUnsignedInteger size){ return MallocT<char>((size_t)size); }
+#ifdef SQUIRREL_DEFAULT_ALLOCATOR
+void *sq_vm_malloc(SQUnsignedInteger size) { return MallocT<char>((size_t)size); }
-void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return ReallocT<char>(static_cast<char*>(p), (size_t)size); }
+void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size) { return ReallocT<char>(static_cast<char*>(p), (size_t)size); }
-void sq_vm_free(void *p, SQUnsignedInteger size){ free(p); }
+void sq_vm_free(void *p, SQUnsignedInteger size) { free(p); }
+#endif