summaryrefslogtreecommitdiff
path: root/src/core/alloc_func.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-11 20:23:38 +0000
committersmatz <smatz@openttd.org>2008-02-11 20:23:38 +0000
commitf19eca0905389586d4a171bba3e044cf3357eef6 (patch)
tree385716e6b5f4563484639b6dd1694fd8fed1a1e3 /src/core/alloc_func.cpp
parentf175e462081e9b0c6e75fccdbe9cb8469bacd55e (diff)
downloadopenttd-f19eca0905389586d4a171bba3e044cf3357eef6.tar.xz
(svn r12115) -Codechange: move malloc/realloc error messages to separate file to spare 4-8kB of binary size
Diffstat (limited to 'src/core/alloc_func.cpp')
-rw-r--r--src/core/alloc_func.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/alloc_func.cpp b/src/core/alloc_func.cpp
new file mode 100644
index 000000000..930482aa7
--- /dev/null
+++ b/src/core/alloc_func.cpp
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+/** @file alloc_func.cpp functions to 'handle' memory allocation errors */
+
+#include "../stdafx.h"
+#include "alloc_func.hpp"
+
+/**
+ * Function to exit with an error message after malloc() or calloc() have failed
+ * @param size number of bytes we tried to allocate
+ */
+void MallocError(size_t size)
+{
+ error("Out of memory. Cannot allocate %i bytes", size);
+}
+
+/**
+ * Function to exit with an error message after realloc() have failed
+ * @param size number of bytes we tried to allocate
+ */
+void ReallocError(size_t size)
+{
+ error("Out of memory. Cannot reallocate %i bytes", size);
+}