use static memory instead of heap memory

This commit is contained in:
anod 2023-03-12 00:20:47 +08:00
parent 3113d223e7
commit 5a04b7a734

View File

@ -39,6 +39,7 @@ typedef struct
static CheatLib gblcht = {0, 0, NULL, 0, 0};
static CheatSet gblset = {0, 0, {0,0,0}, NULL, NULL};
static char sermem[1024*6];
#define ACL_MAGIC_CODE 0x4c4341
#define ACL_GBA_CODELEN 4
@ -142,16 +143,16 @@ static int32_t bin_search( FHandle fd, acl_text_t game )
}
uint32_t size = ACL_SERIAL_LEN(gblcht.serc);
char *serials = (char*)malloc( size );
char *serials = &sermem[0];//(char*)malloc( size );
if( serials == NULL ){
return -ACHTLIB_NOMEM;
}log("alloc serial: %08x with size: %d", serials, size);
}//log("alloc serial: %08x with size: %d", serials, size);
uint32_t readed;
if( RES_OK != fReadSize(fd, serials, size, &readed)
|| readed != size )
{
free( serials );
//free( serials );
return -ACHTLIB_INVALID;
}
@ -172,9 +173,9 @@ static int32_t bin_search( FHandle fd, acl_text_t game )
start = mid + 1;
}
else end = mid - 1;
}log("free serial: %08x", serials);
free( serials );
log("after free");
}//log("free serial: %08x", serials);
//free( serials );
//log("after free");
return found < 0 ? -ACHTLIB_NOT_FOUND : found;
}