diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index 50e30e4c6..dd37f5d2b 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -125,9 +125,8 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheatManager::addOneShot(const string& name, const string& code) { + // Evaluate this cheat once, and then immediately discard it shared_ptr cheat = createCheat(name, code); - - // Evaluate this cheat once, and then immediately delete it if(cheat) cheat->evaluate(); } diff --git a/src/tools/check-sig.cxx b/src/tools/check-sig.cxx index 8585191cb..1f2caec72 100644 --- a/src/tools/check-sig.cxx +++ b/src/tools/check-sig.cxx @@ -6,6 +6,7 @@ #include #include +#include "../common/UniquePtr.hxx" using namespace std; using uInt8 = unsigned char; @@ -55,12 +56,12 @@ int main(int ac, char* av[]) int i_size = (int) in.tellg(); in.seekg(0, ios::beg); - uInt8* image = new uInt8[i_size]; - in.read((char*)(image), i_size); + unique_ptr image = make_ptr(i_size); + in.read((char*)(image.get()), i_size); in.close(); int s_size = 0; - uInt8* sig = new uInt8[strlen(av[2])/2]; + unique_ptr sig = make_ptr(strlen(av[2])/2); istringstream buf(av[2]); uInt32 c; @@ -72,7 +73,7 @@ int main(int ac, char* av[]) // cerr << "sig size = " << hex << s_size << endl; list locations; - int result = searchForBytes(image+offset, i_size-offset, sig, s_size, locations); + int result = searchForBytes(image.get()+offset, i_size-offset, sig.get(), s_size, locations); if(result > 0) { cout << setw(3) << result << " hits: \'" << av[2] << "\' - \"" << av[1] << "\" @"; @@ -81,8 +82,5 @@ int main(int ac, char* av[]) cout << endl; } - delete[] image; - delete[] sig; - return 0; } diff --git a/src/tools/romtohex.cxx b/src/tools/romtohex.cxx index 92c6dc9b7..a3b12e80c 100644 --- a/src/tools/romtohex.cxx +++ b/src/tools/romtohex.cxx @@ -9,8 +9,13 @@ #include #include #include + +#include "../common/UniquePtr.hxx" using namespace std; +using uInt8 = unsigned char; +using uInt32 = unsigned int; + int main(int ac, char* av[]) { if(ac < 2) @@ -33,8 +38,8 @@ int main(int ac, char* av[]) int len = (int)in.tellg(); in.seekg(0, ios::beg); - unsigned char* data = new unsigned char[len]; - in.read((char*)data, len); + unique_ptr data = make_ptr(len); + in.read((char*)data.get(), len); in.close(); cout << "SIZE = " << len << endl << " "; @@ -49,6 +54,5 @@ int main(int ac, char* av[]) cout << endl << " "; } cout << endl; - delete[] data; } }