From d872c0560a0de6db8632f1ad68edf96b5ed7eb87 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Wed, 26 Oct 2016 10:37:28 +0100 Subject: [PATCH] cdvdgigaherz: Use unique_ptr for src --- plugins/cdvdGigaherz/src/CDVD.cpp | 7 +++---- plugins/cdvdGigaherz/src/CDVD.h | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/cdvdGigaherz/src/CDVD.cpp b/plugins/cdvdGigaherz/src/CDVD.cpp index 499389093d..befaf42692 100644 --- a/plugins/cdvdGigaherz/src/CDVD.cpp +++ b/plugins/cdvdGigaherz/src/CDVD.cpp @@ -123,7 +123,7 @@ std::atomic s_keepalive_is_open; bool disc_has_changed = false; bool weAreInNewDiskCB = false; -IOCtlSrc *src; +std::unique_ptr src; char throwaway[2352]; extern s32 prefetch_last_lba; @@ -203,7 +203,7 @@ s32 CALLBACK CDVDopen(const char *pTitleFilename) // open device file try { - src = new IOCtlSrc(drive); + src = std::unique_ptr(new IOCtlSrc(drive)); } catch (std::runtime_error &ex) { fputs(ex.what(), stdout); return -1; @@ -221,8 +221,7 @@ void CALLBACK CDVDclose() StopKeepAliveThread(); cdvdStopThread(); //close device - delete src; - src = NULL; + src.reset(); } void CALLBACK CDVDshutdown() diff --git a/plugins/cdvdGigaherz/src/CDVD.h b/plugins/cdvdGigaherz/src/CDVD.h index 2c362c4796..32796f5f50 100644 --- a/plugins/cdvdGigaherz/src/CDVD.h +++ b/plugins/cdvdGigaherz/src/CDVD.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -83,7 +84,7 @@ public: bool DiscReady(); }; -extern IOCtlSrc *src; +extern std::unique_ptr src; void configure();