summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-25 09:48:53 +0000
committerrubidium <rubidium@openttd.org>2007-12-25 09:48:53 +0000
commitbf98e25e43c3f6efe207c3dde1732d44c34ac285 (patch)
tree7d96120bc1feabf7069c9cd673a8da769e8f90fd
parente2f79f0eb5d602b77bf72a2b4adca50f0a2056db (diff)
downloadopenttd-bf98e25e43c3f6efe207c3dde1732d44c34ac285.tar.xz
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
-rw-r--r--src/ai/ai.cpp2
-rw-r--r--src/ai/default/default.cpp1
-rw-r--r--src/airport.cpp1
-rw-r--r--src/aystar.cpp2
-rw-r--r--src/blitter/32bpp_anim.cpp2
-rw-r--r--src/blitter/8bpp_optimized.cpp2
-rw-r--r--src/bmp.cpp2
-rw-r--r--src/console.cpp2
-rw-r--r--src/core/alloc_func.hpp84
-rw-r--r--src/core/math_func.hpp12
-rw-r--r--src/fileio.cpp1
-rw-r--r--src/fileio.h1
-rw-r--r--src/fios.cpp2
-rw-r--r--src/fontcache.cpp2
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/heightmap.cpp2
-rw-r--r--src/helpers.hpp42
-rw-r--r--src/industry_gui.cpp1
-rw-r--r--src/landscape.cpp1
-rw-r--r--src/livery.h1
-rw-r--r--src/map.cpp2
-rw-r--r--src/misc/blob.hpp6
-rw-r--r--src/network/core/packet.cpp1
-rw-r--r--src/network/core/tcp.cpp1
-rw-r--r--src/network/core/udp.cpp1
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_data.cpp2
-rw-r--r--src/network/network_gamelist.cpp2
-rw-r--r--src/network/network_gui.cpp1
-rw-r--r--src/network/network_server.cpp2
-rw-r--r--src/newgrf.cpp1
-rw-r--r--src/newgrf.h1
-rw-r--r--src/newgrf_config.cpp1
-rw-r--r--src/newgrf_engine.cpp1
-rw-r--r--src/newgrf_gui.cpp1
-rw-r--r--src/newgrf_station.cpp1
-rw-r--r--src/newgrf_station.h1
-rw-r--r--src/newgrf_storage.cpp1
-rw-r--r--src/newgrf_storage.h2
-rw-r--r--src/newgrf_text.cpp1
-rw-r--r--src/newgrf_townname.cpp1
-rw-r--r--src/oldpool.cpp2
-rw-r--r--src/openttd.cpp1
-rw-r--r--src/openttd.h1
-rw-r--r--src/order_cmd.cpp1
-rw-r--r--src/queue.cpp2
-rw-r--r--src/saveload.cpp1
-rw-r--r--src/screenshot.cpp2
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/sound.cpp2
-rw-r--r--src/sound/win32_s.cpp2
-rw-r--r--src/spritecache.cpp2
-rw-r--r--src/spriteloader/grf.cpp1
-rw-r--r--src/spriteloader/png.cpp1
-rw-r--r--src/station.cpp1
-rw-r--r--src/station_cmd.cpp1
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/strgen/strgen.cpp2
-rw-r--r--src/string.cpp2
-rw-r--r--src/strings.cpp1
-rw-r--r--src/texteff.cpp1
-rw-r--r--src/tgp.cpp2
-rw-r--r--src/thread.cpp2
-rw-r--r--src/town.h1
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/vehicle.cpp1
-rw-r--r--src/vehicle_gui.cpp1
-rw-r--r--src/video/dedicated_v.cpp1
-rw-r--r--src/win32.cpp2
-rw-r--r--src/window.cpp2
73 files changed, 144 insertions, 101 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp
index 3a4a435a1..4a075b3ad 100644
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -5,7 +5,7 @@
#include "../variables.h"
#include "../command_func.h"
#include "../network/network.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "ai.h"
#include "default/default.h"
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 93f1309dc..b16fd8e30 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -25,7 +25,6 @@
#include "../../variables.h"
#include "../../bridge.h"
#include "../../date.h"
-#include "../../helpers.hpp"
#include "../../tunnelbridge_map.h"
#include "default.h"
diff --git a/src/airport.cpp b/src/airport.cpp
index 2fd5c09a1..f32df3302 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -11,6 +11,7 @@
#include "airport_movement.h"
#include "date.h"
#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
/* Uncomment this to print out a full report of the airport-structure
* You should either use
diff --git a/src/aystar.cpp b/src/aystar.cpp
index cb4f3ab72..99ca1b207 100644
--- a/src/aystar.cpp
+++ b/src/aystar.cpp
@@ -21,7 +21,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "aystar.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
int _aystar_stats_open_size;
int _aystar_stats_closed_size;
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 0b6e86230..40bf358db 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -1,7 +1,7 @@
/* $Id$ */
#include "../stdafx.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "../gfx_func.h"
#include "../zoom_func.h"
#include "../debug.h"
diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp
index b795e2891..7b7165975 100644
--- a/src/blitter/8bpp_optimized.cpp
+++ b/src/blitter/8bpp_optimized.cpp
@@ -5,7 +5,7 @@
#include "../stdafx.h"
#include "../zoom_func.h"
#include "../debug.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "8bpp_optimized.hpp"
static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
diff --git a/src/bmp.cpp b/src/bmp.cpp
index 0dc5cd8f2..c5677fbd7 100644
--- a/src/bmp.cpp
+++ b/src/bmp.cpp
@@ -3,9 +3,9 @@
/** @file bmp.cpp */
#include "stdafx.h"
-#include "helpers.hpp"
#include "bmp.h"
#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
{
diff --git a/src/console.cpp b/src/console.cpp
index 7d0efa6dc..f18c6749c 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -15,10 +15,10 @@
#include <stdarg.h>
#include <string.h>
#include "console.h"
-#include "helpers.hpp"
#include "network/network.h"
#include "network/network_data.h"
#include "network/network_server.h"
+#include "core/alloc_func.hpp"
#define ICON_BUFFER 79
#define ICON_HISTORY_SIZE 20
diff --git a/src/core/alloc_func.hpp b/src/core/alloc_func.hpp
new file mode 100644
index 000000000..5d88e64e8
--- /dev/null
+++ b/src/core/alloc_func.hpp
@@ -0,0 +1,84 @@
+/* $Id$ */
+
+/** @file alloc_func.hpp Functions related to the allocation of memory */
+
+#ifndef ALLOC_FUNC_HPP
+#define ALLOC_FUNC_HPP
+
+/**
+ * Simplified allocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains garbage data (i.e. possibly non-zero values).
+ * @param T the type of the variable(s) to allocation.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
+{
+ /*
+ * MorphOS cannot handle 0 elements allocations, or rather that always
+ * returns NULL. So we do that for *all* allocations, thus causing it
+ * to behave the same on all OSes.
+ */
+ if (num_elements == 0) return NULL;
+
+ T *t_ptr = (T*)malloc(num_elements * sizeof(T));
+ if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
+ return t_ptr;
+}
+
+/**
+ * Simplified allocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains all zero values.
+ * @param T the type of the variable(s) to allocation.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
+{
+ /*
+ * MorphOS cannot handle 0 elements allocations, or rather that always
+ * returns NULL. So we do that for *all* allocations, thus causing it
+ * to behave the same on all OSes.
+ */
+ if (num_elements == 0) return NULL;
+
+ T *t_ptr = (T*)calloc(num_elements, sizeof(T));
+ if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
+ return t_ptr;
+}
+
+/**
+ * Simplified reallocation function that allocates the specified number of
+ * elements of the given type. It also explicitly casts it to the requested
+ * type. It extends/shrinks the memory allocation given in t_ptr.
+ * @note throws an error when there is no memory anymore.
+ * @note the memory contains all zero values.
+ * @param T the type of the variable(s) to allocation.
+ * @param t_ptr the previous allocation to extend/shrink.
+ * @param num_elements the number of elements to allocate of the given type.
+ * @return NULL when num_elements == 0, non-NULL otherwise.
+ */
+template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
+{
+ /*
+ * MorphOS cannot handle 0 elements allocations, or rather that always
+ * returns NULL. So we do that for *all* allocations, thus causing it
+ * to behave the same on all OSes.
+ */
+ if (num_elements == 0) {
+ free(t_ptr);
+ return NULL;
+ }
+
+ t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
+ if (t_ptr == NULL) error("Out of memory. Cannot reallocate %i bytes", num_elements * sizeof(T));
+ return t_ptr;
+}
+
+#endif /* ALLOC_FUNC_HPP */
diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp
index c05e7ffeb..e20dc6065 100644
--- a/src/core/math_func.hpp
+++ b/src/core/math_func.hpp
@@ -211,4 +211,16 @@ template<typename T> static inline bool IsInsideMM(const T x, const uint min, co
return (uint)(x - min) < (max - min);
}
+/**
+ * Type safe swap operation
+ * @param a variable to swap with b
+ * @param b variable to swap with a
+ */
+template<typename T> void Swap(T& a, T& b)
+{
+ T t = a;
+ a = b;
+ b = t;
+}
+
#endif /* MATH_FUNC_HPP */
diff --git a/src/fileio.cpp b/src/fileio.cpp
index b7a679e1f..3190013ca 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -10,6 +10,7 @@
#include "variables.h"
#include "debug.h"
#include "fios.h"
+#include "core/alloc_func.hpp"
#ifdef WIN32
#include <windows.h>
#else
diff --git a/src/fileio.h b/src/fileio.h
index 3ca2f3534..9e589ba71 100644
--- a/src/fileio.h
+++ b/src/fileio.h
@@ -5,7 +5,6 @@
#ifndef FILEIO_H
#define FILEIO_H
-#include "helpers.hpp"
#include <map>
#include <string>
diff --git a/src/fios.cpp b/src/fios.cpp
index 2dc10002c..b2352d957 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -10,10 +10,10 @@
#include "variables.h"
#include "functions.h"
#include "heightmap.h"
-#include "helpers.hpp"
#include "table/strings.h"
#include "fios.h"
#include "fileio.h"
+#include "core/alloc_func.hpp"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index e693d0a7d..1f48d20db 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -11,10 +11,10 @@
#include "spritecache.h"
#include "string.h"
#include "fontcache.h"
-#include "helpers.hpp"
#include "spriteloader/spriteloader.hpp"
#include "blitter/factory.hpp"
#include "gfx_func.h"
+#include "core/alloc_func.hpp"
#ifdef WITH_FREETYPE
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 9b186b127..f4b7e09a7 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -13,9 +13,9 @@
#include "economy_func.h"
#include "variables.h"
#include "date.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
static uint _legend_excluded_players;
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index ca655ee75..09606ce37 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -18,10 +18,10 @@
#include "train.h"
#include "date.h"
#include "group.h"
-#include "helpers.hpp"
#include "viewport.h"
#include "debug.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
struct Sorting {
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index b287748f6..cf23bb1cf 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -14,8 +14,8 @@
#include "gui.h"
#include "saveload.h"
#include "bmp.h"
-#include "helpers.hpp"
#include "gfx_func.h"
+#include "core/alloc_func.hpp"
/**
* Convert RGB colors to Grayscale using 29.9% Red, 58.7% Green, 11.4% Blue
diff --git a/src/helpers.hpp b/src/helpers.hpp
deleted file mode 100644
index aaa38acb5..000000000
--- a/src/helpers.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* $Id$ */
-
-/** @file helpers.hpp */
-
-#ifndef HELPERS_HPP
-#define HELPERS_HPP
-
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
-{
- T *t_ptr = (T*)malloc(num_elements * sizeof(T));
- if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
- return t_ptr;
-}
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
-{
- T *t_ptr = (T*)calloc(num_elements, sizeof(T));
- if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
- return t_ptr;
-}
-/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
-* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
-template <typename T> FORCEINLINE T* ReallocT(T* t_ptr, size_t num_elements)
-{
- t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
- if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot reallocate %i bytes", num_elements * sizeof(T));
- return t_ptr;
-}
-
-
-/** type safe swap operation */
-template<typename T> void Swap(T& a, T& b)
-{
- T t = a;
- a = b;
- b = t;
-}
-
-#endif /* HELPERS_HPP */
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 1ca817d26..2dbdf993a 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -17,7 +17,6 @@
#include "industry.h"
#include "town.h"
#include "variables.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "newgrf.h"
#include "newgrf_callbacks.h"
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 0abef68eb..3c87ce6c2 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -22,6 +22,7 @@
#include "tgp.h"
#include "genworld.h"
#include "tile_cmd.h"
+#include "core/alloc_func.hpp"
extern const TileTypeProcs
_tile_type_clear_procs,
diff --git a/src/livery.h b/src/livery.h
index 74797926b..51da83c51 100644
--- a/src/livery.h
+++ b/src/livery.h
@@ -5,7 +5,6 @@
#ifndef LIVERY_H
#define LIVERY_H
-#include "helpers.hpp"
/* List of different livery schemes. */
enum LiveryScheme {
diff --git a/src/map.cpp b/src/map.cpp
index 33e255e7b..cd65a146e 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -7,9 +7,9 @@
#include "debug.h"
#include "functions.h"
#include "map.h"
-#include "helpers.hpp"
#include "direction_func.h"
#include "core/bitmath_func.hpp"
+#include "core/alloc_func.hpp"
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* VStudio 2005 is stupid! */
/* Why the hell is that not in all MSVC headers?? */
diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp
index fd08385f8..c485e9207 100644
--- a/src/misc/blob.hpp
+++ b/src/misc/blob.hpp
@@ -2,8 +2,10 @@
/** @file blob.hpp */
-#ifndef BLOB_HPP
-#define BLOB_HPP
+#ifndef BLOB_HPP
+#define BLOB_HPP
+
+#include "../core/alloc_func.hpp"
/** Type-safe version of memcpy().
* @param d destination buffer
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp
index 21c6b5ba6..d31375183 100644
--- a/src/network/core/packet.cpp
+++ b/src/network/core/packet.cpp
@@ -8,7 +8,6 @@
#include "../../stdafx.h"
#include "../../string.h"
-#include "../../helpers.hpp"
#include "packet.h"
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index 1520a55f4..deb72a60b 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -16,7 +16,6 @@
#include "../network_data.h"
#include "packet.h"
#include "tcp.h"
-#include "../../helpers.hpp"
/** Very ugly temporary hack !!! */
void NetworkTCPSocketHandler::Initialize()
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 58c586813..8cd22ce62 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -10,6 +10,7 @@
#include "../../debug.h"
#include "../../core/bitmath_func.hpp"
#include "../../core/math_func.hpp"
+#include "../../core/alloc_func.hpp"
#include "packet.h"
#include "udp.h"
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index ed47953ed..e1ac2d5c5 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -19,7 +19,7 @@
#include "../console.h"
#include "../variables.h"
#include "../ai/ai.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "../fileio.h"
#include "../md5.h"
#include "../strings_func.h"
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index 8dddce4bf..8e525cec9 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -9,7 +9,7 @@
#include "network_client.h"
#include "../command_func.h"
#include "../callback_table.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
// Add a command to the local command queue
void NetworkAddCommandQueue(NetworkTCPSocketHandler *cs, CommandPacket *cp)
diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp
index ade47801c..91c469537 100644
--- a/src/network/network_gamelist.cpp
+++ b/src/network/network_gamelist.cpp
@@ -10,7 +10,7 @@
#include "../stdafx.h"
#include "../debug.h"
#include "../newgrf_config.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "core/game.h"
#include "network_udp.h"
#include "network_gamelist.h"
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 20e8f18a9..485db74d4 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -26,7 +26,6 @@
#include "../string.h"
#include "../town.h"
#include "../newgrf.h"
-#include "../helpers.hpp"
#define BGC 5
#define BTC 15
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 5406f9d06..47cd19228 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -23,7 +23,7 @@
#include "../station.h"
#include "../variables.h"
#include "../genworld.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "../fileio.h"
// This file handles all the server-commands
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 8ad70d175..5a481000b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -33,7 +33,6 @@
#include "newgrf_house.h"
#include "newgrf_sound.h"
#include "newgrf_spritegroup.h"
-#include "helpers.hpp"
#include "table/town_land.h"
#include "cargotype.h"
#include "industry.h"
diff --git a/src/newgrf.h b/src/newgrf.h
index 3785fcc5d..283b35ec8 100644
--- a/src/newgrf.h
+++ b/src/newgrf.h
@@ -8,7 +8,6 @@
#include "station.h"
#include "town.h"
#include "newgrf_config.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "industry.h"
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 326719a61..fb6a84424 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -13,7 +13,6 @@
#include "network/network_data.h"
#include "newgrf.h"
#include "newgrf_config.h"
-#include "helpers.hpp"
#include "fileio.h"
#include "fios.h"
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 3f6f90dfb..7afb4a91f 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -19,7 +19,6 @@
#include "newgrf_spritegroup.h"
#include "newgrf_cargo.h"
#include "date.h"
-#include "helpers.hpp"
#include "cargotype.h"
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 84532927d..531cf3aa5 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -13,7 +13,6 @@
#include "table/sprites.h"
#include "newgrf.h"
#include "newgrf_config.h"
-#include "helpers.hpp"
#include "strings_func.h"
/** Parse an integerlist string and set each found value
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 788a07207..6d0db261e 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -19,7 +19,6 @@
#include "newgrf_station.h"
#include "newgrf_spritegroup.h"
#include "date.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "town_map.h"
#include "newgrf_town.h"
diff --git a/src/newgrf_station.h b/src/newgrf_station.h
index a14330303..b9a671804 100644
--- a/src/newgrf_station.h
+++ b/src/newgrf_station.h
@@ -8,7 +8,6 @@
#include "engine.h"
#include "newgrf_callbacks.h"
#include "newgrf_cargo.h"
-#include "helpers.hpp"
enum StationClassID {
STAT_CLASS_BEGIN = 0, ///< the lowest valid value
diff --git a/src/newgrf_storage.cpp b/src/newgrf_storage.cpp
index c5c06b2f9..526e00313 100644
--- a/src/newgrf_storage.cpp
+++ b/src/newgrf_storage.cpp
@@ -3,7 +3,6 @@
/** @file newgrf_storage.cpp Functionality related to the temporary and persistent storage arrays for NewGRFs. */
#include "stdafx.h"
-#include "helpers.hpp"
#include "newgrf_storage.h"
#include <set>
diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h
index cf7690a92..e3320d055 100644
--- a/src/newgrf_storage.h
+++ b/src/newgrf_storage.h
@@ -5,6 +5,8 @@
#ifndef NEWGRF_STORAGE_H
#define NEWGRF_STORAGE_H
+#include "core/alloc_func.hpp"
+
/**
* Base class for all NewGRF storage arrays. Nothing fancy, only here
* so we have a generalised class to use.
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index cd241632f..c3df2f1be 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -18,7 +18,6 @@
#include "newgrf.h"
#include "newgrf_text.h"
#include "table/control_codes.h"
-#include "helpers.hpp"
#include "date.h"
#include "strings_func.h"
diff --git a/src/newgrf_townname.cpp b/src/newgrf_townname.cpp
index 1d46e1983..90855aa27 100644
--- a/src/newgrf_townname.cpp
+++ b/src/newgrf_townname.cpp
@@ -11,6 +11,7 @@
#include "table/strings.h"
#include "newgrf_townname.h"
#include "string.h"
+#include "core/alloc_func.hpp"
static GRFTownName *_grf_townnames = NULL;
diff --git a/src/oldpool.cpp b/src/oldpool.cpp
index 3d8326828..9c447f421 100644
--- a/src/oldpool.cpp
+++ b/src/oldpool.cpp
@@ -7,7 +7,7 @@
#include "debug.h"
#include "functions.h"
#include "oldpool.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
/**
* Clean a pool in a safe way (does free all blocks)
diff --git a/src/openttd.cpp b/src/openttd.cpp
index d1e85eb15..004bb3275 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -9,7 +9,6 @@
#include "driver.h"
#include "saveload.h"
#include "map.h"
-#include "helpers.hpp"
#include "openttd.h"
#include "table/strings.h"
diff --git a/src/openttd.h b/src/openttd.h
index 3df5e7403..a067f312d 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -8,7 +8,6 @@
#define VARDEF extern
#endif
-#include "helpers.hpp"
#include "strings_type.h"
#include "map.h"
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index fe1634b47..16649da07 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -20,6 +20,7 @@
#include "cargotype.h"
#include "aircraft.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
DEFINE_OLD_POOL_GENERIC(Order, Order)
diff --git a/src/queue.cpp b/src/queue.cpp
index 177845865..ebd3a37ef 100644
--- a/src/queue.cpp
+++ b/src/queue.cpp
@@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "queue.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
/*
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 22cb8588d..93edeeafb 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -29,6 +29,7 @@
#include "window_func.h"
#include "strings_func.h"
#include "gfx_func.h"
+#include "core/alloc_func.hpp"
#include <list>
extern const uint16 SAVEGAME_VERSION = 83;
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index c77dce722..d95ce98a9 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -12,11 +12,11 @@
#include "variables.h"
#include "date.h"
#include "string.h"
-#include "helpers.hpp"
#include "blitter/factory.hpp"
#include "fileio.h"
#include "strings_func.h"
#include "zoom_func.h"
+#include "core/alloc_func.hpp"
char _screenshot_format_name[8];
uint _num_screenshot_formats;
diff --git a/src/settings.cpp b/src/settings.cpp
index 52e1e4fa2..d78c7b752 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -40,7 +40,6 @@
#include "date.h"
#include "rail.h"
#include "train.h"
-#include "helpers.hpp"
#include "news.h"
#include "window_func.h"
#include "strings_func.h"
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 175939d20..bdd8e161f 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -22,7 +22,6 @@
#include "settings.h"
#include "vehicle.h"
#include "date.h"
-#include "helpers.hpp"
#include "newgrf_townname.h"
#include "strings_func.h"
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index c816b809b..2dbbd9f9b 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -14,9 +14,9 @@
#include "signs.h"
#include "debug.h"
#include "variables.h"
-#include "helpers.hpp"
#include "command_func.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
static const Sign **_sign_sort;
static uint _num_sign_sort;
diff --git a/src/sound.cpp b/src/sound.cpp
index 0e8acfc3c..62176687a 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -13,9 +13,9 @@
#include "viewport.h"
#include "fileio.h"
#include "newgrf_sound.h"
-#include "helpers.hpp"
#include "fios.h"
#include "window_gui.h"
+#include "core/alloc_func.hpp"
static uint _file_count;
static FileEntry *_files;
diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp
index 578011986..3efff337a 100644
--- a/src/sound/win32_s.cpp
+++ b/src/sound/win32_s.cpp
@@ -5,7 +5,7 @@
#include "../driver.h"
#include "../functions.h"
#include "../mixer.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include "win32_s.h"
#include <windows.h>
#include <mmsystem.h>
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index ad22fff89..cf587c0ea 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -11,8 +11,8 @@
#include "spritecache.h"
#include "table/sprites.h"
#include "fileio.h"
-#include "helpers.hpp"
#include "spriteloader/grf.hpp"
+#include "core/alloc_func.hpp"
#ifdef WITH_PNG
#include "spriteloader/png.hpp"
#endif /* WITH_PNG */
diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp
index e225ea52d..d0bc0e334 100644
--- a/src/spriteloader/grf.cpp
+++ b/src/spriteloader/grf.cpp
@@ -6,6 +6,7 @@
#include "../gfx_func.h"
#include "../fileio.h"
#include "../debug.h"
+#include "../core/alloc_func.hpp"
#include "grf.hpp"
bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, const char *filename, uint8 file_slot, uint32 file_pos)
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index 0a626d5fe..a252433bd 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -9,6 +9,7 @@
#include "../fileio.h"
#include "../variables.h"
#include "../debug.h"
+#include "../core/alloc_func.hpp"
#include "png.hpp"
#include <png.h>
diff --git a/src/station.cpp b/src/station.cpp
index e713ceee8..c03e77e85 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -28,7 +28,6 @@
#include "newgrf_station.h"
#include "yapf/yapf.h"
#include "date.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "roadveh.h"
#include "station_gui.h"
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 899aab80a..08ca8c0e2 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -34,7 +34,6 @@
#include "newgrf_station.h"
#include "yapf/yapf.h"
#include "date.h"
-#include "helpers.hpp"
#include "misc/autoptr.hpp"
#include "road_type.h"
#include "road_internal.h" /* For drawing catenary/checking road removal */
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index e4378eac8..26b48fe4f 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -20,11 +20,11 @@
#include "date.h"
#include "vehicle.h"
#include "table/sprites.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "station_gui.h"
#include "station.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 342678ba7..f981e7cd8 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -3,7 +3,7 @@
#include "../stdafx.h"
#include "../string.h"
#include "../table/control_codes.h"
-#include "../helpers.hpp"
+#include "../core/alloc_func.hpp"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/src/string.cpp b/src/string.cpp
index 0a5343df5..7441ecc27 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -7,8 +7,8 @@
#include "functions.h"
#include "string.h"
#include "table/control_codes.h"
-#include "helpers.hpp"
#include "debug.h"
+#include "core/alloc_func.hpp"
#include <stdarg.h>
#include <ctype.h> // required for tolower()
diff --git a/src/strings.cpp b/src/strings.cpp
index 862d5b47b..101ec69b1 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -23,7 +23,6 @@
#include "date.h"
#include "industry.h"
#include "fileio.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "group.h"
#include "debug.h"
diff --git a/src/texteff.cpp b/src/texteff.cpp
index c5a33ca72..56ab24d92 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -20,6 +20,7 @@
#include "video/video_driver.hpp"
#include "transparency.h"
#include "strings_func.h"
+#include "core/alloc_func.hpp"
enum {
MAX_TEXTMESSAGE_LENGTH = 200,
diff --git a/src/tgp.cpp b/src/tgp.cpp
index 0d5c27870..b65c39451 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -15,7 +15,7 @@
#include "tgp.h"
#include "console.h"
#include "genworld.h"
-#include "helpers.hpp"
+#include "core/alloc_func.hpp"
/*
*
diff --git a/src/thread.cpp b/src/thread.cpp
index 61b6ccabb..4e4f065fb 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -4,8 +4,8 @@
#include "stdafx.h"
#include "thread.h"
+#include "core/alloc_func.hpp"
#include <stdlib.h>
-#include "helpers.hpp"
#if defined(__AMIGA__) || defined(PSP) || defined(NO_THREADS)
OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) { return NULL; }
diff --git a/src/town.h b/src/town.h
index d59c6c03e..0c22618ab 100644
--- a/src/town.h
+++ b/src/town.h
@@ -8,7 +8,6 @@
#include "oldpool.h"
#include "player.h"
#include "functions.h"
-#include "helpers.hpp"
enum {
HOUSE_NO_CLASS = 0,
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 1f74d79cd..e5921b922 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -17,9 +17,9 @@
#include "player.h"
#include "network/network.h"
#include "variables.h"
-#include "helpers.hpp"
#include "strings_func.h"
#include "economy_func.h"
+#include "core/alloc_func.hpp"
enum TownAuthorityWidget {
TWA_CLOSEBOX = 0,
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 79138d85c..b5826bb17 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -38,7 +38,6 @@
#include "newgrf_callbacks.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
-#include "helpers.hpp"
#include "group.h"
#include "order.h"
#include "strings_func.h"
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 3c1613212..7b6c5ac84 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -28,7 +28,6 @@
#include "aircraft.h"
#include "roadveh.h"
#include "depot.h"
-#include "helpers.hpp"
#include "cargotype.h"
#include "group.h"
#include "group_gui.h"
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 70732bb73..5bc52032f 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -14,6 +14,7 @@
#include "../genworld.h"
#include "../fileio.h"
#include "../blitter/factory.hpp"
+#include "../core/alloc_func.hpp"
#include "dedicated_v.h"
#ifdef BEOS_NET_SERVER
diff --git a/src/win32.cpp b/src/win32.cpp
index b2c780cdd..4b3ebc6fb 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "debug.h"
#include "functions.h"
-#include "helpers.hpp"
#include "saveload.h"
#include "string.h"
#include "gfx_func.h"
@@ -22,6 +21,7 @@
#include "win32.h"
#include "fios.h" // opendir/readdir/closedir
#include "fileio.h"
+#include "core/alloc_func.hpp"
#include <ctype.h>
#include <tchar.h>
#include <errno.h>
diff --git a/src/window.cpp b/src/window.cpp
index 4a9a4e600..605679f48 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -14,10 +14,10 @@
#include "variables.h"
#include "table/sprites.h"
#include "genworld.h"
-#include "helpers.hpp"
#include "blitter/factory.hpp"
#include "window_gui.h"
#include "zoom_func.h"
+#include "core/alloc_func.hpp"
/* delta between mouse cursor and upper left corner of dragged window */
static Point _drag_delta;