diff options
author | yexo <yexo@openttd.org> | 2011-03-03 21:24:03 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2011-03-03 21:24:03 +0000 |
commit | 261b34b70503ba2e2a803cd9664f35b2f2c4ae14 (patch) | |
tree | f2019a81e19e9f4f5c2922965f0a057b6fb64517 /src/sprite.cpp | |
parent | 91ddf07c80b82e780fae8e6212a20f9afc031a80 (diff) | |
download | openttd-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.cpp | 16 |
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; +} |