nmlgc / ssg

秋霜玉 / Shuusou Gyoku
MIT License
20 stars 5 forks source link

Replace manual Win32 memory management with C++ smart pointers #13

Closed nmlgc closed 11 months ago

nmlgc commented 1 year ago

The game crashes quite frequently in debug configurations due to what seems to be use-after-free bugs. Clearly defined pointer ownership can help here, and replacing all the LocalAlloc() and LocalFree() calls can also help with portability.

The 西方Project lens ball animation (LENS.CPP) looks to be the most critical place that should be covered first.

nmlgc commented 1 year ago

By removing some of the allocations, we'd also shorten the (already miniscule) load times by another bit.

nmlgc commented 11 months ago

Implemented it fairly quickly at the end of P0251, finishing with 443752ab5f016910392b138d062cc2ac691c0314. The DirectSound and MIDI code still uses LocalAlloc() and LocalFree(), but it does not matter there as that code can't be ported away from Windows anyway.