Clean up memory management

This commit is contained in:
Zachary Levy
2026-04-20 20:27:40 -07:00
parent 64de816647
commit f85187eff3
4 changed files with 213 additions and 22 deletions

View File

@@ -83,6 +83,7 @@ rectangle_gradient :: proc(
temp_allocator := context.temp_allocator,
) {
vertices := make([]Vertex, 6, temp_allocator)
defer delete(vertices, temp_allocator)
corner_top_left := [2]f32{rect.x, rect.y}
corner_top_right := [2]f32{rect.x + rect.width, rect.y}
@@ -115,6 +116,7 @@ circle_sector :: proc(
vertex_count := segment_count * 3
vertices := make([]Vertex, vertex_count, temp_allocator)
defer delete(vertices, temp_allocator)
start_radians := math.to_radians(start_angle)
end_radians := math.to_radians(end_angle)
@@ -167,6 +169,7 @@ circle_gradient :: proc(
vertex_count := segment_count * 3
vertices := make([]Vertex, vertex_count, temp_allocator)
defer delete(vertices, temp_allocator)
step_angle := math.TAU / f32(segment_count)
@@ -238,6 +241,7 @@ triangle_lines :: proc(
temp_allocator := context.temp_allocator,
) {
vertices := make([]Vertex, 18, temp_allocator)
defer delete(vertices, temp_allocator)
write_offset := 0
if !needs_transform(origin, rotation) {
@@ -273,6 +277,7 @@ triangle_fan :: proc(
triangle_count := len(points) - 2
vertex_count := triangle_count * 3
vertices := make([]Vertex, vertex_count, temp_allocator)
defer delete(vertices, temp_allocator)
if !needs_transform(origin, rotation) {
for i in 1 ..< len(points) - 1 {
@@ -312,6 +317,7 @@ triangle_strip :: proc(
triangle_count := len(points) - 2
vertex_count := triangle_count * 3
vertices := make([]Vertex, vertex_count, temp_allocator)
defer delete(vertices, temp_allocator)
if !needs_transform(origin, rotation) {
for i in 0 ..< triangle_count {