- [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

3
gif.c
View File

@@ -434,6 +434,9 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
// sizeof( screen_descriptor_t ) = 8! // sizeof( screen_descriptor_t ) = 8!
READ(&screen_descriptor, 7); READ(&screen_descriptor, 7);
if (w) *w = screen_descriptor.width;
if (h) *h = screen_descriptor.height;
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1; color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1;
if ( screen_descriptor.fields & 0x80 ) if ( screen_descriptor.fields & 0x80 )

View File

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

View File

@@ -16,7 +16,7 @@ void JD8_Quit();
void JD8_ClearScreen(Uint8 color); void JD8_ClearScreen(Uint8 color);
JD8_Surface JD8_NewSurface(); JD8_Surface JD8_NewSurface(const int w, const int h);
JD8_Surface JD8_LoadSurface(const char *file); JD8_Surface JD8_LoadSurface(const char *file);

View File

@@ -57,7 +57,7 @@ namespace module
{ {
bool eixir = false; bool eixir = false;
fondo_temp = JD8_NewSurface(); fondo_temp = JD8_NewSurface(320, 200);
JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp); JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp);
JD8_Blit(fondo_temp); JD8_Blit(fondo_temp);