Skip to content

singleton: migrate fl/stl/allocator.cpp.hpp state (Tier 1a) #3484

Closed

Description

@zackees

Part of #3481 (Tier 1a).

Task

Wrap the three namespace-scope statics in src/fl/stl/allocator.cpp.hpp in fl::Singleton<T> so --gc-sections can elide them when the allocator hook / slab registry is unused.

Current state (line numbers from scan)

// src/fl/stl/allocator.cpp.hpp
MallocFreeHook* gMallocFreeHook = nullptr;   // L64
SlabRegistryEntry slab_registry[SLAB_REGISTRY_MAX];  // L252
int slab_registry_count = 0;                 // L253

Approach

  1. Introduce struct AllocatorState { MallocFreeHook* hook = nullptr; SlabRegistryEntry slabs[SLAB_REGISTRY_MAX]{}; int slab_count = 0; };
  2. Route all call sites through fl::Singleton<AllocatorState>::instance().hook etc.
  3. Delete the file-scope statics.
  4. Verify bash test --cpp passes.
  5. Verify bash bloat esp32dev shows the storage moved to elidable status.

Acceptance criteria

  • bash lint no longer flags this file for SingletonElisionChecker.
  • All allocator tests pass.
  • Elision confirmed via bash bloat before/after diff.

Activity

  1. added
    type: feature
    priority: medium
    area: core
    on Jul 1, 2026
  2. moved this from Triage to Done in FastLED Trackeron Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: mediumtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions