From d96a4f52fb89d1549b3029738edc4cd4f0fcfc71 Mon Sep 17 00:00:00 2001 From: MineRobber9000 Date: Tue, 7 Jul 2026 12:57:16 -0400 Subject: [PATCH] Fix resource leak in Asteroids and Sounds demos --- assets/asteroids.ms | 9 ++++++++- assets/sounds.ms | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/assets/asteroids.ms b/assets/asteroids.ms index 08019ad..2847390 100644 --- a/assets/asteroids.ms +++ b/assets/asteroids.ms @@ -407,6 +407,12 @@ render = function raylib.DrawFPS end function +unload = function + raylib.UnloadTexture spriteSheetTex + raylib.UnloadFont scoreFont + sounds.unload +end function + run = function init while true @@ -417,7 +423,8 @@ run = function raylib.EndDrawing if raylib.IsKeyPressed(raylib.KEY_ESCAPE) or raylib.IsKeyPressed(raylib.KEY_Q) then break yield - end while + end while + unload end function if locals == globals then run diff --git a/assets/sounds.ms b/assets/sounds.ms index 7647f3e..1b3e397 100644 --- a/assets/sounds.ms +++ b/assets/sounds.ms @@ -92,6 +92,12 @@ boom = makeSound(samples) sounds = [null, wooble, boop, pew, white, hit, boom] +unload = function + for sound in sounds + if sound!=null then raylib.UnloadSound sound + end for +end function + run = function x = 100; y = 100 dx = 10; dy = 10 @@ -112,6 +118,7 @@ run = function raylib.EndDrawing yield end while + unload end function if locals == globals then run