summaryrefslogtreecommitdiff
path: root/src/sprite.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-03-03 21:24:03 +0000
committeryexo <yexo@openttd.org>2011-03-03 21:24:03 +0000
commit261b34b70503ba2e2a803cd9664f35b2f2c4ae14 (patch)
treef2019a81e19e9f4f5c2922965f0a057b6fb64517 /src/sprite.cpp
parent91ddf07c80b82e780fae8e6212a20f9afc031a80 (diff)
downloadopenttd-261b34b70503ba2e2a803cd9664f35b2f2c4ae14.tar.xz
(svn r22175) -Fix: [NewGRF] memory leak if a station newgrf contains prop 09 twice for the same station id
Diffstat (limited to 'src/sprite.cpp')
-rw-r--r--src/sprite.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sprite.cpp b/src/sprite.cpp
index 2e453941a..4e41be4f1 100644
--- a/src/sprite.cpp
+++ b/src/sprite.cpp
@@ -14,6 +14,8 @@
#include "viewport_func.h"
#include "landscape.h"
#include "spritecache.h"
+#include "core/alloc_func.hpp"
+#include "core/mem_func.hpp"
/**
@@ -108,3 +110,17 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig
}
}
}
+
+/** Create a copy of an existing DrawTileSeqStruct array. */
+const DrawTileSeqStruct *CopyDrawTileSeqStruct(const DrawTileSeqStruct *dtss)
+{
+ const DrawTileSeqStruct *element;
+
+ size_t count = 1; // 1 for the terminator
+ foreach_draw_tile_seq(element, dtss) count++;
+
+ DrawTileSeqStruct *copy = MallocT<DrawTileSeqStruct>(count);
+ MemCpyT(copy, dtss, count);
+
+ return copy;
+}