Skip to content

Commit

Permalink
replace "malloc" with "memalloc"
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawmario committed Jan 5, 2025
1 parent 8053d28 commit 2879d83
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions extension/src/sm64_surfaces.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <sm64_surfaces.hpp>

#include <cstdlib>
#include <cstring>

#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/math.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
Expand Down Expand Up @@ -46,7 +43,7 @@ void SM64Surfaces::static_surfaces_load(godot::PackedVector3Array p_vertexes, go

const real_t scale_factor = sm64_global->get_scale_factor();
const int64_t vertexes_size = p_vertexes.size();
struct SM64Surface *surface_array = (SM64Surface *) malloc(sizeof(SM64Surface) * vertexes_size / 3);
struct SM64Surface* surface_array = static_cast<SM64Surface*>(memalloc(sizeof(SM64Surface) * vertexes_size / 3));
godot::Ref<SM64SurfaceProperties> default_surface_properties;

default_surface_properties.instantiate();
Expand Down Expand Up @@ -79,7 +76,7 @@ void SM64Surfaces::static_surfaces_load(godot::PackedVector3Array p_vertexes, go

sm64_static_surfaces_load(surface_array, si);

::free(surface_array);
memfree(surface_array);
}

int SM64Surfaces::surface_object_create(godot::PackedVector3Array p_vertexes, godot::Vector3 p_position, godot::Vector3 p_rotation, godot::TypedArray<SM64SurfaceProperties> p_surface_properties_array)
Expand All @@ -94,7 +91,7 @@ int SM64Surfaces::surface_object_create(godot::PackedVector3Array p_vertexes, go
const int64_t vertexes_size = p_vertexes.size();
struct SM64SurfaceObject surface_object;
int id;
struct SM64Surface *surface_array = (SM64Surface *) malloc(sizeof(SM64Surface) * vertexes_size / 3);
struct SM64Surface* surface_array = static_cast<SM64Surface*>(memalloc(sizeof(SM64Surface) * vertexes_size / 3));
godot::Ref<SM64SurfaceProperties> default_surface_properties;

default_surface_properties.instantiate();
Expand Down Expand Up @@ -138,7 +135,7 @@ int SM64Surfaces::surface_object_create(godot::PackedVector3Array p_vertexes, go

id = sm64_surface_object_create(&surface_object);

::free(surface_array);
memfree(surface_array);

return id;
}
Expand Down

0 comments on commit 2879d83

Please sign in to comment.