Skip to content

Conversation

@rory-cd
Copy link

@rory-cd rory-cd commented Jan 19, 2026

Description

Background

SplashKit bundles allow sets of resources to be loaded and freed as a group. For more information, see the documentation. The free_resource_bundle function is supposed to free every resource in the bundle at once.

Problem

The free_resource_bundle function currently does not free bitmaps. This was shown in the "Bundles" test results - every other resource was freed successfully, except the bitmaps.

Cause

When a bundle is loaded, each line of the bundle text file is analysed and run through a SWITCH in the load_resource_bundle function, loading the resource based on its type. Then the resources are added to a list (vector), which is stored as a field in the bundle. Meaning each bundle in memory has a list of corresponding resources. However, after the resources are loaded, their existence is checked to ensure the loading was successful. If it wasn't, the function returns early and the resource isn't added to the list.

In the case of a bitmap, we have:

case IMAGE_RESOURCE:
    rb_load_bitmap(line_name, line_path);
    if ( ! has_resource_bundle(line_name) ) return;
    break;

Which means the condition checks for the bundle, not a bitmap. So the bitmap is loaded, but not added to the bundle's list of resources, and therefore not freed by free_resource_bundle.

Fix

This is a very small and simple fix, changing the IMAGE_RESOURCE case so it checks has_bitmap rather than has_resource_bundle.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran the "Bundles" test in sktest in WSL and MSYS2. Also ran skunit_tests.

Results of Bundles test

bundle-test-results

Testing Checklist

  • Tested with sktest
  • Tested with skunit_tests

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have requested a review from ... on the Pull Request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant