mirror of https://github.com/OpenRCT2/OpenRCT2.git
remove rct2_malloc, rct2_realloc and rct2_free
This commit is contained in:
parent
b7484db239
commit
730463dbbb
|
@ -54,7 +54,7 @@ int gfx_load_g1()
|
|||
SDL_RWread(file, g1Elements, header.num_entries * sizeof(rct_g1_element), 1);
|
||||
|
||||
// Read element data
|
||||
_g1Buffer = rct2_malloc(header.total_size);
|
||||
_g1Buffer = malloc(header.total_size);
|
||||
SDL_RWread(file, _g1Buffer, header.total_size, 1);
|
||||
|
||||
SDL_RWclose(file);
|
||||
|
|
44
src/rct2.c
44
src/rct2.c
|
@ -587,47 +587,3 @@ void get_local_time()
|
|||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = t.hour;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = t.minute;
|
||||
}
|
||||
|
||||
/**
|
||||
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to allocate memory if RCT2 is still able to
|
||||
* free it.
|
||||
* rct2: 0x004068B2
|
||||
*/
|
||||
void *rct2_malloc(size_t numBytes)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
return RCT2_CALLFUNC_1(0x004068B2, void*, size_t, numBytes);
|
||||
#else
|
||||
//log_warning("call rct's function");
|
||||
return malloc(numBytes);
|
||||
#endif // __WINDOWS__
|
||||
}
|
||||
|
||||
/**
|
||||
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to reallocate memory if RCT2 is still able to
|
||||
* free it.
|
||||
* rct2: 0x004068BD
|
||||
*/
|
||||
void *rct2_realloc(void *block, size_t numBytes)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
return RCT2_CALLFUNC_2(0x004068BD, void*, void*, size_t, block, numBytes);
|
||||
#else
|
||||
//log_warning("call rct's function");
|
||||
return realloc(block, numBytes);
|
||||
#endif // __WINDOWS__
|
||||
}
|
||||
|
||||
/**
|
||||
* RCT2 and this DLL can not free each other's allocated memory blocks. Use this to free memory that was allocated by RCT2.
|
||||
* rct2: 0x004068CD
|
||||
*/
|
||||
void rct2_free(void *block)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
RCT2_CALLPROC_1(0x004068CD, void*, block);
|
||||
#else
|
||||
//log_warning("call rct's function");
|
||||
free(block);
|
||||
#endif // __WINDOWS__
|
||||
}
|
||||
|
|
|
@ -272,9 +272,6 @@ const char *get_file_path(int pathId);
|
|||
void get_system_info();
|
||||
void get_system_time();
|
||||
void get_local_time();
|
||||
void *rct2_malloc(size_t numBytes);
|
||||
void *rct2_realloc(void *block, size_t numBytes);
|
||||
void rct2_free(void *block);
|
||||
void rct2_quit();
|
||||
|
||||
int rct2_open_file(const char *path);
|
||||
|
|
|
@ -667,7 +667,7 @@ static void setup_in_use_selection_flags(){
|
|||
static int sub_6AB211(){
|
||||
uint32 total_objects = gInstalledObjectsCount;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) = rct2_malloc(total_objects);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) = malloc(total_objects);
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) == NULL){
|
||||
log_error("Failed to allocate memory for object flag list.");
|
||||
|
@ -717,12 +717,9 @@ static int sub_6AB211(){
|
|||
*
|
||||
* rct2: 0x006AB316
|
||||
*/
|
||||
static void editor_object_flags_free(){
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) == NULL){
|
||||
return;
|
||||
}
|
||||
rct2_free(RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*));
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) = NULL;
|
||||
static void editor_object_flags_free()
|
||||
{
|
||||
SafeFree(RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3654,7 +3654,7 @@ void map_reorganise_elements()
|
|||
{
|
||||
platform_set_cursor(CURSOR_ZZZ);
|
||||
|
||||
rct_map_element* new_map_elements = rct2_malloc(0x30000 * sizeof(rct_map_element));
|
||||
rct_map_element* new_map_elements = malloc(0x30000 * sizeof(rct_map_element));
|
||||
rct_map_element* new_elements_pointer = new_map_elements;
|
||||
|
||||
if (new_map_elements == NULL || new_map_elements == (rct_map_element*)-1){
|
||||
|
@ -3680,7 +3680,7 @@ void map_reorganise_elements()
|
|||
memcpy(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element), new_map_elements, num_elements * sizeof(rct_map_element));
|
||||
memset(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element) + num_elements, 0, (0x30000 - num_elements) * sizeof(rct_map_element));
|
||||
|
||||
rct2_free(new_map_elements);
|
||||
free(new_map_elements);
|
||||
|
||||
map_update_tile_pointers();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue