VERSIÓ 1.6.1:
- [FIX] Memory leaks en gif.h - [FIX] Memory leak en backends/SDL3/input.cpp - [FIX] Bugaco enorme i silenciós en file.cpp - [FIX] Els arxius de font s'han de carregar com a arxius de text - [NEW] Afegit perfil 'linux_sanitize' per a detectar problemes de memòria
This commit is contained in:
1 parent
75ddf7ce1a
commit
9e2b89a4ee
6 files changed
+18
-14
No files matched your search
@@ -12,6 +12,13 @@ executable = mini_debug
|
||||
sourcepath = source+
|
||||
buildpath = build
|
||||
|
||||
[linux_sanitize] default
|
||||
cppflags = -D LUA_USE_LINUX -D DEBUG -g -Wall -std=c++20 -fsanitize=address -fno-omit-frame-pointer -Isource
|
||||
libs = -fsanitize=address -lSDL3 -lGL
|
||||
executable = mini_san
|
||||
sourcepath = source+
|
||||
buildpath = build
|
||||
|
||||
[windows]
|
||||
cppflags = -Wall -Os -ffunction-sections -fdata-sections -std=c++20 -Isource
|
||||
libs = icon.res -Wl,--gc-sections -lmingw32 -lSDL3 -lopengl32 -static-libstdc++ -static-libgcc -lpthread -mwindows
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace backend
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_free(joysticks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace mini
|
||||
|
||||
char *getfilebuffer(const char *resourcename, int& filesize, const bool zero_terminate) {
|
||||
FILE *f = getfilepointer(resourcename, filesize, true);
|
||||
char* buffer = (char*)malloc(zero_terminate?filesize:filesize+1);
|
||||
char* buffer = (char*)malloc(zero_terminate?filesize+1:filesize);
|
||||
fread(buffer, filesize, 1, f);
|
||||
if (zero_terminate) buffer[filesize]=0;
|
||||
fclose(f);
|
||||
@@ -158,7 +158,7 @@ namespace mini
|
||||
|
||||
char *getfilebufferex(const char *filename, int& filesize, const bool zero_terminate) {
|
||||
FILE *f = getfilepointerex(filename, filesize, true);
|
||||
char* buffer = (char*)malloc(zero_terminate?filesize:filesize+1);
|
||||
char* buffer = (char*)malloc(zero_terminate?filesize+1:filesize);
|
||||
fread(buffer, filesize, 1, f);
|
||||
if (zero_terminate) buffer[filesize]=0;
|
||||
fclose(f);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace mini
|
||||
// Carregar l'arxiu de disc
|
||||
int size;
|
||||
char *buffer;
|
||||
buffer = file::getfilebuffer(filename, size);
|
||||
buffer = file::getfilebuffer(filename, size, true);
|
||||
|
||||
// Si no s'ha pogut, petar
|
||||
if (!buffer) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define MINI_VERSION "1.6.0"
|
||||
#define MINI_VERSION "1.6.1"
|
||||
+6
-10
@@ -5,6 +5,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#define READ(dst, size) memcpy(dst, buffer, size); buffer += size
|
||||
#define SKIP(size) buffer += size
|
||||
|
||||
struct rgb { uint8_t r, g, b; };
|
||||
|
||||
@@ -116,6 +117,7 @@ void uncompress( int code_length, const uint8_t *input, int input_length, uint8_
|
||||
}
|
||||
out += match_len;
|
||||
}
|
||||
free(dictionary);
|
||||
}
|
||||
|
||||
static int read_sub_blocks( uint8_t* buffer, uint8_t **data )
|
||||
@@ -137,7 +139,7 @@ static int read_sub_blocks( uint8_t* buffer, uint8_t **data )
|
||||
return data_length;
|
||||
}
|
||||
|
||||
uint8_t* process_image_descriptor( uint8_t* buffer, rgb *gct, int gct_size, int resolution_bits )
|
||||
uint8_t* process_image_descriptor( uint8_t* buffer)
|
||||
{
|
||||
image_descriptor_t image_descriptor;
|
||||
READ(&image_descriptor, 9);
|
||||
@@ -180,21 +182,15 @@ uint32_t* LoadPalette(uint8_t *buffer, uint16_t *size = NULL )
|
||||
|
||||
static uint8_t* LoadGif(uint8_t *buffer, uint16_t* w, uint16_t* h)
|
||||
{
|
||||
int global_color_table_size = 0; // number of entries in global_color_table
|
||||
rgb *global_color_table = NULL;
|
||||
|
||||
buffer += 6; // Ignore header
|
||||
*w = *((uint16_t*)buffer); buffer+=2;
|
||||
*h = *((uint16_t*)buffer); buffer+=2;
|
||||
const uint8_t fields = *buffer; buffer+=3;
|
||||
|
||||
const int color_resolution_bits = ( ( fields & 0x70 ) >> 4 ) + 1;
|
||||
|
||||
if ( fields & 0x80 )
|
||||
{
|
||||
global_color_table_size = 1 << ( ( ( fields & 0x07 ) + 1 ) );
|
||||
global_color_table = (rgb*)malloc( 3 * global_color_table_size );
|
||||
READ(global_color_table, 3 * global_color_table_size);
|
||||
int global_color_table_size = 1 << ( ( ( fields & 0x07 ) + 1 ) );
|
||||
SKIP(global_color_table_size*3);
|
||||
}
|
||||
|
||||
uint8_t block_type = 0x0;
|
||||
@@ -206,7 +202,7 @@ static uint8_t* LoadGif(uint8_t *buffer, uint16_t* w, uint16_t* h)
|
||||
switch ( block_type )
|
||||
{
|
||||
case 0x2C:
|
||||
return process_image_descriptor(buffer, global_color_table, global_color_table_size, color_resolution_bits);
|
||||
return process_image_descriptor(buffer);
|
||||
case 0x21:
|
||||
buffer++; //size = *(buffer++); buffer += size;
|
||||
do { size = *(buffer++); buffer += size; } while (size != 0);
|
||||
|
||||
Reference in new issue
Block a user