Dont leak memory when calling load surfaces multiple times
This commit is contained in:
@@ -6,3 +6,5 @@
|
||||
run-test
|
||||
*.z64
|
||||
*.so
|
||||
compile_commands.json
|
||||
/.cache/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h> // For printf before exit, TODO remove
|
||||
|
||||
#include "../shim.h"
|
||||
#include "../include/PR/os_cont.h"
|
||||
|
||||
+2
-2
@@ -122,9 +122,9 @@ SM64_LIB_FN void sm64_static_surfaces_load( const struct SM64Surface *surfaceArr
|
||||
surfaces_load_static( surfaceArray, numSurfaces );
|
||||
}
|
||||
|
||||
SM64_LIB_FN uint32_t sm64_mario_create( int16_t x, int16_t y, int16_t z )
|
||||
SM64_LIB_FN int32_t sm64_mario_create( int16_t x, int16_t y, int16_t z )
|
||||
{
|
||||
uint32_t marioIndex = obj_pool_alloc_index( &s_mario_instance_pool, sizeof( struct MarioInstance ));
|
||||
int32_t marioIndex = obj_pool_alloc_index( &s_mario_instance_pool, sizeof( struct MarioInstance ));
|
||||
struct MarioInstance *newInstance = s_mario_instance_pool.objects[marioIndex];
|
||||
|
||||
newInstance->globalState = global_state_create();
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ extern SM64_LIB_FN void sm64_global_terminate( void );
|
||||
|
||||
extern SM64_LIB_FN void sm64_static_surfaces_load( const struct SM64Surface *surfaceArray, uint32_t numSurfaces );
|
||||
|
||||
extern SM64_LIB_FN uint32_t sm64_mario_create( int16_t x, int16_t y, int16_t z );
|
||||
extern SM64_LIB_FN int32_t sm64_mario_create( int16_t x, int16_t y, int16_t z );
|
||||
extern SM64_LIB_FN void sm64_mario_tick( uint32_t marioId, const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers );
|
||||
extern SM64_LIB_FN void sm64_mario_delete( uint32_t marioId );
|
||||
|
||||
|
||||
@@ -223,6 +223,9 @@ struct Surface *loaded_surface_iter_get_at_index( uint32_t groupIndex, uint32_t
|
||||
|
||||
void surfaces_load_static( const struct SM64Surface *surfaceArray, uint32_t numSurfaces )
|
||||
{
|
||||
if( s_static_surface_list != NULL )
|
||||
free( s_static_surface_list );
|
||||
|
||||
s_static_surface_count = numSurfaces;
|
||||
s_static_surface_list = malloc( sizeof( struct Surface ) * numSurfaces );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user