diff options
| author | Max Horn | 2008-11-03 15:15:32 +0000 | 
|---|---|---|
| committer | Max Horn | 2008-11-03 15:15:32 +0000 | 
| commit | 188da3547fa39b09c6c129196c0e0ba36ce7cc8c (patch) | |
| tree | 00579abc4ac6520ee45f2dfd9339709c3cdb0601 /gui | |
| parent | 57a3d2ae3b68be705e648e39dc188f381bcc11fa (diff) | |
| download | scummvm-rg350-188da3547fa39b09c6c129196c0e0ba36ce7cc8c.tar.gz scummvm-rg350-188da3547fa39b09c6c129196c0e0ba36ce7cc8c.tar.bz2 scummvm-rg350-188da3547fa39b09c6c129196c0e0ba36ce7cc8c.zip | |
Instead of allocating (and leaking, in case of an error) a 64k table with at most 256 entries, use a HashMap
svn-id: r34878
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/ThemeEngine.cpp | 17 | 
1 files changed, 7 insertions, 10 deletions
| diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index ddf346dc7b..4181d69514 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1039,9 +1039,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int  	uint colorsFound = 0;  	const OverlayColor *src = (const OverlayColor*)cursor->pixels; -	byte *table = new byte[65536]; -	assert(table); -	memset(table, 0, sizeof(byte)*65536); +	Common::HashMap<int, int>	colorToIndex;  	byte r, g, b; @@ -1051,16 +1049,16 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int  	_cursor = new byte[_cursorWidth * _cursorHeight];  	assert(_cursor); -	memset(_cursor, 255, sizeof(byte)*_cursorWidth*_cursorHeight); +	memset(_cursor, 0xFF, sizeof(byte) * _cursorWidth * _cursorHeight);  	for (uint y = 0; y < _cursorHeight; ++y) {  		for (uint x = 0; x < _cursorWidth; ++x) {  			_system->colorToRGB(src[x], r, g, b);  			uint16 col = RGBToColor<ColorMasks<565> >(r, g, b); -			if (!table[col] && col != transparency) { -				table[col] = colorsFound++; +			if (!colorToIndex.contains(col) && col != transparency) { +				const int index = colorsFound++; +				colorToIndex[col] = index; -				uint index = table[col];  				_cursorPal[index * 4 + 0] = r;  				_cursorPal[index * 4 + 1] = g;  				_cursorPal[index * 4 + 2] = b; @@ -1073,7 +1071,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int  			}  			if (col != transparency) { -				uint index = table[col]; +				const int index = colorToIndex[col];  				_cursor[y * _cursorWidth + x] = index;  			}  		} @@ -1081,8 +1079,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int  	}  	_useCursor = true; -	delete[] table; -	 +  	return true;  } | 
