(svn r22175) -Fix: [NewGRF] memory leak if a station newgrf contains prop 09 twice for the same station id

This commit is contained in:
yexo
2011-03-03 21:24:03 +00:00
parent 91ddf07c80
commit 261b34b705
5 changed files with 33 additions and 12 deletions

View File

@@ -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;
}