Free remaining global allocs
This commit is contained in:
@@ -61,44 +61,11 @@ static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f };
|
||||
static Vec3s gVec3sZero = { 0, 0, 0 };
|
||||
static Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
static struct GraphNodeObject *init_graph_node_object( Vec3f pos, Vec3s angle, Vec3f scale) {
|
||||
struct GraphNodeObject *graphNode = malloc(sizeof(struct GraphNodeObject));
|
||||
|
||||
//init_scene_graph_node_links(&graphNode->node, GRAPH_NODE_TYPE_OBJECT);
|
||||
|
||||
graphNode->node.type = GRAPH_NODE_TYPE_OBJECT;
|
||||
graphNode->node.flags = GRAPH_RENDER_ACTIVE;
|
||||
graphNode->node.prev = &graphNode->node;
|
||||
graphNode->node.next = &graphNode->node;
|
||||
graphNode->node.parent = NULL;
|
||||
graphNode->node.children = NULL;
|
||||
|
||||
vec3f_copy(graphNode->pos, pos);
|
||||
vec3f_copy(graphNode->scale, scale);
|
||||
vec3s_copy(graphNode->angle, angle);
|
||||
vec3f_copy(graphNode->cameraToObject, gVec3fZero);
|
||||
|
||||
graphNode->sharedChild = NULL;
|
||||
graphNode->throwMatrix = NULL;
|
||||
graphNode->animInfo.animID = 0;
|
||||
graphNode->animInfo.curAnim = NULL;
|
||||
graphNode->animInfo.animFrame = 0;
|
||||
graphNode->animInfo.animFrameAccelAssist = 0;
|
||||
graphNode->animInfo.animAccel = 0x10000;
|
||||
graphNode->animInfo.animTimer = 0;
|
||||
graphNode->node.flags |= GRAPH_RENDER_HAS_ANIMATION;
|
||||
|
||||
return graphNode;
|
||||
}
|
||||
|
||||
static struct Object *try_allocate_object(void) {
|
||||
struct ObjectNode *nextObj;
|
||||
nextObj = (struct ObjectNode *) malloc(sizeof(struct Object));
|
||||
nextObj->prev = NULL;
|
||||
nextObj->next = NULL;
|
||||
|
||||
init_graph_node_object(gVec3fZero, gVec3sZero, gVec3fOne);
|
||||
|
||||
return (struct Object *) nextObj;
|
||||
}
|
||||
|
||||
@@ -191,7 +158,6 @@ static struct Object *spawn_object_at_origin(void) {
|
||||
obj->parentObj = NULL;
|
||||
obj->header.gfx.areaIndex = 0;
|
||||
obj->header.gfx.activeAreaIndex = 0;
|
||||
// geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, gLoadedGraphNodes[model], gVec3fZero, gVec3sZero);
|
||||
geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, NULL, gVec3fZero, gVec3sZero);
|
||||
|
||||
return obj;
|
||||
|
||||
+16
-32
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define SM64_LIB_EXPORT
|
||||
#include "libsm64.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
@@ -50,38 +50,22 @@ static void update_button( bool on, u16 button )
|
||||
}
|
||||
}
|
||||
|
||||
static struct Camera *hack_build_camera( void )
|
||||
static struct Area *allocate_area( void )
|
||||
{
|
||||
struct Camera *result = malloc( sizeof( struct Camera ));
|
||||
memset( result, 0, sizeof( struct Camera ));
|
||||
struct Area *result = malloc( sizeof( struct Area ));
|
||||
memset( result, 0, sizeof( struct Area ));
|
||||
|
||||
result->flags = 1;
|
||||
result->camera = malloc( sizeof( struct Camera ));
|
||||
memset( result->camera, 0, sizeof( struct Camera ));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct Area *hack_build_area( void )
|
||||
static void free_area( struct Area *area )
|
||||
{
|
||||
struct Area *result = malloc( sizeof( struct Area ));
|
||||
|
||||
result->index = 0;
|
||||
result->flags = 1;
|
||||
result->terrainType = TERRAIN_GRASS;
|
||||
result->unk04 = NULL;
|
||||
result->terrainData = NULL;
|
||||
result->surfaceRooms = NULL;
|
||||
result->macroObjects = NULL;
|
||||
result->warpNodes = NULL;
|
||||
result->paintingWarpNodes = NULL;
|
||||
result->instantWarps = NULL;
|
||||
result->objectSpawnInfos = NULL;
|
||||
result->camera = hack_build_camera();
|
||||
result->unused28 = NULL;
|
||||
result->whirlpools[0] = NULL;
|
||||
result->whirlpools[1] = NULL;
|
||||
result->dialog[0] = 0;
|
||||
result->dialog[1] = 0;
|
||||
result->musicParam = 0;
|
||||
result->musicParam2 = 0;
|
||||
|
||||
return result;
|
||||
free( area->camera );
|
||||
free( area );
|
||||
}
|
||||
|
||||
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
||||
@@ -98,7 +82,7 @@ SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugP
|
||||
|
||||
gCurrSaveFileNum = 1;
|
||||
gMarioObject = hack_allocate_mario();
|
||||
gCurrentArea = hack_build_area();
|
||||
gCurrentArea = allocate_area();
|
||||
gCurrentObject = gMarioObject;
|
||||
|
||||
s_mario_geo_pool = alloc_only_pool_init();
|
||||
@@ -186,8 +170,8 @@ SM64_LIB_FN void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct S
|
||||
|
||||
SM64_LIB_FN void sm64_global_terminate( void )
|
||||
{
|
||||
//deallocate area,
|
||||
//deallocate mario object and graph node
|
||||
free( gMarioObject );
|
||||
free_area( gCurrentArea );
|
||||
|
||||
global_state_bind( NULL );
|
||||
global_state_destroy( s_global_state );
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef BUILDING_SM64_DLL
|
||||
#ifdef SM64_LIB_EXPORT
|
||||
#define SM64_LIB_FN __declspec(dllexport)
|
||||
#else
|
||||
#define SM64_LIB_FN __declspec(dllimport)
|
||||
|
||||
Reference in New Issue
Block a user