Changeset - r20522:f59a7a990690
[Not reviewed]
master
0 2 0
rubidium - 11 years ago 2013-06-30 20:40:49
rubidium@openttd.org
(svn r25546) -Fix: two small memory leaks
2 files changed with 4 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/script_scanner.cpp
Show inline comments
 
@@ -55,48 +55,49 @@ ScriptScanner::ScriptScanner() :
 
	engine(NULL),
 
	main_script(NULL),
 
	tar_file(NULL)
 
{
 
}
 

	
 
void ScriptScanner::Initialize(const char *name)
 
{
 
	this->engine = new Squirrel(name);
 

	
 
	/* Mark this class as global pointer */
 
	this->engine->SetGlobalPointer(this);
 

	
 
	this->RegisterAPI(this->engine);
 
	this->RescanDir();
 

	
 
	this->engine->ResetCrashed();
 
}
 

	
 
ScriptScanner::~ScriptScanner()
 
{
 
	this->Reset();
 

	
 
	free(this->main_script);
 
	free(this->tar_file);
 
	delete this->engine;
 
}
 

	
 
void ScriptScanner::RescanDir()
 
{
 
	/* Forget about older scans */
 
	this->Reset();
 

	
 
	/* Scan for scripts */
 
	this->Scan(this->GetFileName(), this->GetDirectory());
 
}
 

	
 
void ScriptScanner::Reset()
 
{
 
	ScriptInfoList::iterator it = this->info_list.begin();
 
	for (; it != this->info_list.end(); it++) {
 
		free((*it).first);
 
		delete (*it).second;
 
	}
 
	it = this->info_single_list.begin();
 
	for (; it != this->info_single_list.end(); it++) {
 
		free((*it).first);
 
	}
 

	
src/viewport.cpp
Show inline comments
 
@@ -144,48 +144,51 @@ struct ViewportDrawer {
 
	int *last_foundation_child[FOUNDATION_PART_END]; ///< Tail of ChildSprite list of the foundations. (index into child_screen_sprites_to_draw)
 
	Point foundation_offset[FOUNDATION_PART_END];    ///< Pixel offset for ground sprites on the foundations.
 
};
 

	
 
static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom);
 

	
 
static ViewportDrawer _vd;
 

	
 
TileHighlightData _thd;
 
static TileInfo *_cur_ti;
 
bool _draw_bounding_boxes = false;
 
bool _draw_dirty_blocks = false;
 
uint _dirty_block_colour = 0;
 

	
 
static Point MapXYZToViewport(const ViewPort *vp, int x, int y, int z)
 
{
 
	Point p = RemapCoords(x, y, z);
 
	p.x -= vp->virtual_width / 2;
 
	p.y -= vp->virtual_height / 2;
 
	return p;
 
}
 

	
 
void DeleteWindowViewport(Window *w)
 
{
 
	if (w->viewport == NULL) return;
 

	
 
	delete w->viewport->overlay;
 
	free(w->viewport);
 
	w->viewport = NULL;
 
}
 

	
 
/**
 
 * Initialize viewport of the window for use.
 
 * @param w Window to use/display the viewport in
 
 * @param x Offset of left edge of viewport with respect to left edge window \a w
 
 * @param y Offset of top edge of viewport with respect to top edge window \a w
 
 * @param width Width of the viewport
 
 * @param height Height of the viewport
 
 * @param follow_flags Flags controlling the viewport.
 
 *        - If bit 31 is set, the lower 20 bits are the vehicle that the viewport should follow.
 
 *        - If bit 31 is clear, it is a #TileIndex.
 
 * @param zoom Zoomlevel to display
 
 */
 
void InitializeWindowViewport(Window *w, int x, int y,
 
	int width, int height, uint32 follow_flags, ZoomLevel zoom)
 
{
 
	assert(w->viewport == NULL);
 

	
 
	ViewportData *vp = CallocT<ViewportData>(1);
 

	
 
	vp->left = x + w->left;
0 comments (0 inline, 0 general)