I looked in OpenXcom code and i have problem with it
![Smiley :)](https://openxcom.org/forum/Smileys/default/smiley.gif)
`Surface::paletteShift` <- i dont like this function
we have this:
https:// store the original palette
_originalColors = (SDL_Color *)malloc(sizeof(SDL_Color) * _surface->format->palette->ncolors);
1) couple of points:
a) why malloc? not beter use `new SDL_Color[_surface->format->palette->ncolors];`?
b) why isnt null assert here? when we call 2 times this function, we will get memory leak.
c) destructor dont delete this memory -> memory leak
d) copy constructor dont copy this
if (i * mul + off < _surface->format->palette->ncolors)
{
newColors[i].r = getPalette()[i * mul + off].r;
newColors[i].g = getPalette()[i * mul + off].g;
newColors[i].b = getPalette()[i * mul + off].b;
}
2) is indented that`mul>1` will leave half of colors in palette black?
if (_originalColors)
{
SDL_SetColors(_surface, _originalColors, 0, 256);
free(_originalColors);
_originalColors = 0;
}
3) `Surface::paletteRestore()` have fixed size 256, this is indented? in `Surface::paletteShift` the ` _surface->format->palette->ncolors` is used. is possible to have less than 256 in normal palette?