Skip to content

Fix memory leaks by using Smart Pointers and RAII Wrappers#1

Closed
buzz wants to merge 1 commit intodeobfuscationfrom
mem-management
Closed

Fix memory leaks by using Smart Pointers and RAII Wrappers#1
buzz wants to merge 1 commit intodeobfuscationfrom
mem-management

Conversation

@buzz
Copy link
Copy Markdown
Owner

@buzz buzz commented Apr 28, 2026

  • Smart Pointer Usage
    • std::unique_ptr is used consistently for exclusive ownership
    • std::shared_ptr is used appropriately for shared resources (Font)
    • All new expressions are wrapped in std::make_unique or std::make_shared
  • RAII Wrappers
    • SDLWindow and SDLRenderer properly wrap SDL resources
    • Font::FontResource wraps SDL_RWops with proper cleanup
    • Image destructor calls SDL_FreeSurface
    • FileStream destructor calls close()
  • Static Resources
    • FontStorage::fontsMap uses std::shared_ptr<Font> - auto-cleanup on program exit
    • RecordStore::opened uses std::unique_ptr<RecordStore> - auto-cleanup on program exit
    • Font::FontResource singleton uses std::shared_ptr - auto-cleanup

Depends on rgimad#37 being merged first.

- Smart Pointer Usage
  - std::unique_ptr is used consistently for exclusive ownership
  - std::shared_ptr is used appropriately for shared resources (Font)
  - All new expressions are wrapped in std::make_unique or std::make_shared
- RAII Wrappers
  - SDLWindow and SDLRenderer properly wrap SDL resources
  - Font::FontResource wraps SDL_RWops with proper cleanup
  - Image destructor calls SDL_FreeSurface
  - FileStream destructor calls close()
- Static Resources
  - FontStorage::fontsMap uses std::shared_ptr<Font> - auto-cleanup on program exit
  - RecordStore::opened uses std::unique_ptr<RecordStore> - auto-cleanup on program exit
  - Font::FontResource singleton uses std::shared_ptr - auto-cleanup
@buzz buzz closed this Apr 28, 2026
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