cdvdgigaherz: Use unique_ptr for src

This commit is contained in:
Jonathan Li 2016-10-26 10:37:28 +01:00
parent f8f79788e4
commit d872c0560a
2 changed files with 5 additions and 5 deletions

View File

@ -123,7 +123,7 @@ std::atomic<bool> s_keepalive_is_open;
bool disc_has_changed = false; bool disc_has_changed = false;
bool weAreInNewDiskCB = false; bool weAreInNewDiskCB = false;
IOCtlSrc *src; std::unique_ptr<IOCtlSrc> src;
char throwaway[2352]; char throwaway[2352];
extern s32 prefetch_last_lba; extern s32 prefetch_last_lba;
@ -203,7 +203,7 @@ s32 CALLBACK CDVDopen(const char *pTitleFilename)
// open device file // open device file
try { try {
src = new IOCtlSrc(drive); src = std::unique_ptr<IOCtlSrc>(new IOCtlSrc(drive));
} catch (std::runtime_error &ex) { } catch (std::runtime_error &ex) {
fputs(ex.what(), stdout); fputs(ex.what(), stdout);
return -1; return -1;
@ -221,8 +221,7 @@ void CALLBACK CDVDclose()
StopKeepAliveThread(); StopKeepAliveThread();
cdvdStopThread(); cdvdStopThread();
//close device //close device
delete src; src.reset();
src = NULL;
} }
void CALLBACK CDVDshutdown() void CALLBACK CDVDshutdown()

View File

@ -22,6 +22,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <memory>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -83,7 +84,7 @@ public:
bool DiscReady(); bool DiscReady();
}; };
extern IOCtlSrc *src; extern std::unique_ptr<IOCtlSrc> src;
void configure(); void configure();