A few more unique_ptr updates.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3174 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2015-06-14 20:48:06 +00:00
parent 8dbd5d7f48
commit 9978baba3a
3 changed files with 13 additions and 12 deletions

View File

@ -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> cheat = createCheat(name, code);
// Evaluate this cheat once, and then immediately delete it
if(cheat)
cheat->evaluate();
}

View File

@ -6,6 +6,7 @@
#include <cstdlib>
#include <list>
#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<uInt8[]> image = make_ptr<uInt8[]>(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<uInt8[]> sig = make_ptr<uInt8[]>(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<int> 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;
}

View File

@ -9,8 +9,13 @@
#include <fstream>
#include <iostream>
#include <cstdlib>
#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<uInt8[]> data = make_ptr<uInt8[]>(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;
}
}