Browse Source

Add some more explanation to Console::drop

pull/17/head
AzureMarker 3 years ago
parent
commit
12ae54c605
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 5
      ctru-rs/src/console.rs

5
ctru-rs/src/console.rs

@ -54,6 +54,11 @@ impl Default for Console { @@ -54,6 +54,11 @@ impl Default for Console {
impl Drop for Console {
fn drop(&mut self) {
unsafe {
// Safety: We are about to deallocate the PrintConsole data pointed
// to by libctru. Without this drop code libctru would have a
// dangling pointer that it writes to on every print. To prevent
// this we replace the console with the default if it was selected.
// Get the current console by replacing it with the default.
let default_console = ctru_sys::consoleGetDefault();
let current_console = ctru_sys::consoleSelect(default_console);

Loading…
Cancel
Save