mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Fix memory leak with ApplyFilter
The intention of the recent refactor was to make it so that the temporary surfaces would be allocated only once, when the mode is enabled, and be freed upon exit. To do this, Graphics.cpp owns the pointers, and passes them to ApplyFilter to modify. Except ApplyFilter doesn't actually modify the pointers, because it's only a single pointer, not a pointer-to-pointer. So every frame of rendering it would actually be creating a new surface and leaking memory. To fix this, they need to be pointer-to-pointer variables that get modified. I also added error logs in case the surface creation failed.
This commit is contained in:
@@ -12,6 +12,6 @@ void DrawPixel(SDL_Surface* surface, int x, int y, SDL_Color color);
|
||||
SDL_Color ReadPixel(const SDL_Surface* surface, int x, int y);
|
||||
|
||||
void UpdateFilter(void);
|
||||
void ApplyFilter(SDL_Surface* src, SDL_Surface* dest);
|
||||
void ApplyFilter(SDL_Surface** src, SDL_Surface** dest);
|
||||
|
||||
#endif /* GRAPHICSUTIL_H */
|
||||
|
||||
Reference in New Issue
Block a user