Simplify the SRAM's representation in NDSCartArgs (#1914)

* Simplify the SRAM's representation in  `NDSCartArgs`

- I overthought this one.
- I could've just checked `args && args->SRAM`, but then some other poor bastard might make this mistake.
- Don't mix `pair`, `optional`, and `unique_ptr` all at once, kids.

* Fix a `nullptr` read
This commit is contained in:
Jesse Talavera
2023-12-15 08:56:10 -05:00
committed by GitHub
parent 24c402af51
commit e1821d0023
3 changed files with 16 additions and 6 deletions

View File

@ -62,9 +62,14 @@ struct NDSCartArgs
std::optional<FATStorageArgs> SDCard = std::nullopt;
/// Save RAM to load into the cartridge.
/// If \c nullopt, then the cart's SRAM buffer will be empty.
/// If \c nullptr, then the cart's SRAM buffer will be empty.
/// Ignored for homebrew ROMs.
std::optional<std::pair<std::unique_ptr<u8[]>, u32>> SRAM = std::nullopt;
std::unique_ptr<u8[]> SRAM = nullptr;
/// The length of the buffer in SRAM.
/// If 0, then the cart's SRAM buffer will be empty.
/// Ignored for homebrew ROMs.
u32 SRAMLength = 0;
};
// CartCommon -- base code shared by all cart types