- [FIX] Small memory leak fixed

This commit is contained in:
2024-02-12 13:15:57 +01:00
parent fe444fc0ec
commit 19df09dddc
4 changed files with 10 additions and 7 deletions

View File

@@ -50,9 +50,9 @@ void JD8_ClearScreen(Uint8 color) {
memset( screen, color, 64000 );
}
JD8_Surface JD8_NewSurface() {
JD8_Surface surface = (JD8_Surface)malloc( 64000 );
memset( surface, 0, 64000 );
JD8_Surface JD8_NewSurface(const int w, const int h) {
JD8_Surface surface = (JD8_Surface)malloc( w * h );
memset( surface, 0, w*h );
return surface;
}
@@ -70,8 +70,8 @@ JD8_Surface JD8_LoadSurface(const char *file) {
exit(1);
}
JD8_Surface image = JD8_NewSurface();
memcpy(image, pixels, 64000);
JD8_Surface image = JD8_NewSurface(w, h);
memcpy(image, pixels, w * h);
free(pixels);
return image;