Some more nullptr and formatting cleanups.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3051 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-07 14:26:56 +00:00
parent 5d6ca08617
commit a9aa84e3a3
9 changed files with 32 additions and 33 deletions

View File

@ -26,7 +26,7 @@ class BankRomCheat : public Cheat
{
public:
BankRomCheat(OSystem& os, const string& name, const string& code);
~BankRomCheat();
virtual ~BankRomCheat();
bool enable();
bool disable();

View File

@ -53,7 +53,7 @@ class Cheat
{
int ret = 0;
for(unsigned int i=0; i<hex.size(); i++) {
for(unsigned int i = 0; i < hex.size(); ++i) {
char c = hex[i];
ret *= 16;

View File

@ -86,7 +86,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
StringList labels;
labels.push_back("Name: ");
labels.push_back("Code: ");
myCheatInput = new InputTextDialog(this, font, labels);
myCheatInput = make_ptr<InputTextDialog>(this, font, labels);
myCheatInput->setTarget(this);
addToFocusList(wid);
@ -100,7 +100,6 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheatCodeDialog::~CheatCodeDialog()
{
delete myCheatInput;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -41,7 +41,7 @@ class CheatCodeDialog : public Dialog
virtual ~CheatCodeDialog();
protected:
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
void loadConfig();
void saveConfig();
@ -53,7 +53,7 @@ class CheatCodeDialog : public Dialog
private:
CheckListWidget* myCheatList;
InputTextDialog* myCheatInput;
unique_ptr<InputTextDialog> myCheatInput;
ButtonWidget* myEditButton;
ButtonWidget* myRemoveButton;

View File

@ -52,7 +52,7 @@ Cheat* CheatManager::add(const string& name, const string& code,
{
Cheat* cheat = createCheat(name, code);
if(!cheat)
return NULL;
return nullptr;
// Delete duplicate entries
for(unsigned int i = 0; i < myCheatList.size(); i++)
@ -129,7 +129,7 @@ void CheatManager::addPerFrame(Cheat* cheat, bool enable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheatManager::addOneShot(const string& name, const string& code)
{
Cheat* cheat = (Cheat*) createCheat(name, code);
Cheat* cheat = createCheat(name, code);
if(!cheat)
return;
@ -142,7 +142,7 @@ void CheatManager::addOneShot(const string& name, const string& code)
Cheat* CheatManager::createCheat(const string& name, const string& code) const
{
if(!isValidCode(code))
return NULL;
return nullptr;
// Create new cheat based on string length
switch(code.size())
@ -160,7 +160,7 @@ Cheat* CheatManager::createCheat(const string& name, const string& code) const
break;
default:
return NULL;
return nullptr;
}
}

View File

@ -26,7 +26,7 @@ class CheetahCheat : public Cheat
{
public:
CheetahCheat(OSystem& os, const string& name, const string& code);
~CheetahCheat();
virtual ~CheetahCheat();
bool enable();
bool disable();

View File

@ -38,7 +38,7 @@ using namespace Common;
CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
: DebuggerSystem(dbg, console),
myOSystem(osystem),
myDebugWidget(0),
myDebugWidget(nullptr),
myAddrToLineIsROM(true),
myRWPortAddress(0),
myLabelLength(8) // longest pre-defined label

View File

@ -121,8 +121,8 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode,
{
assert(_isDirectory);
DIR *dirp = opendir(_path.c_str());
struct dirent *dp;
DIR* dirp = opendir(_path.c_str());
struct dirent* dp;
if (dirp == NULL)
return false;
@ -254,7 +254,7 @@ bool FilesystemNodePOSIX::rename(const string& newfile)
AbstractFSNode* FilesystemNodePOSIX::getParent() const
{
if (_path == "/")
return 0;
return nullptr;
const char *start = _path.c_str();
const char *end = lastPathComponent(_path);

View File

@ -63,10 +63,10 @@ const char* lastPathComponent(const string& str)
if(str.empty())
return "";
const char *start = str.c_str();
const char *cur = start + str.size() - 2;
const char* start = str.c_str();
const char* cur = start + str.size() - 2;
while (cur >= start && *cur != '\\')
while(cur >= start && *cur != '\\')
--cur;
return cur + 1;
@ -103,7 +103,7 @@ void FilesystemNodeWINDOWS::setFlags()
// Check whether it is a directory, and whether the file actually exists
DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str()));
if (fileAttribs == INVALID_FILE_ATTRIBUTES)
if(fileAttribs == INVALID_FILE_ATTRIBUTES)
{
_isDirectory = _isFile = _isValid = false;
}
@ -129,14 +129,14 @@ void FilesystemNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
bool isDirectory, isFile;
// Skip local directory (.) and parent (..)
if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2))
if(!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2))
return;
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false);
if ((isFile && mode == FilesystemNode::kListDirectoriesOnly) ||
(isDirectory && mode == FilesystemNode::kListFilesOnly))
if((isFile && mode == FilesystemNode::kListDirectoriesOnly) ||
(isDirectory && mode == FilesystemNode::kListFilesOnly))
return;
entry._isDirectory = isDirectory;
@ -144,7 +144,7 @@ void FilesystemNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
entry._displayName = asciiName;
entry._path = base;
entry._path += asciiName;
if (entry._isDirectory)
if(entry._isDirectory)
entry._path += "\\";
entry._isValid = true;
entry._isPseudoRoot = false;
@ -224,14 +224,14 @@ bool FilesystemNodeWINDOWS::
//TODO: honor the hidden flag
if (_isPseudoRoot)
if(_isPseudoRoot)
{
// Drives enumeration
TCHAR drive_buffer[100];
GetLogicalDriveStrings(sizeof(drive_buffer) / sizeof(TCHAR), drive_buffer);
for (TCHAR *current_drive = drive_buffer; *current_drive;
current_drive += _tcslen(current_drive) + 1)
for(TCHAR *current_drive = drive_buffer; *current_drive;
current_drive += _tcslen(current_drive) + 1)
{
FilesystemNodeWINDOWS entry;
char drive_name[2];
@ -258,12 +258,12 @@ bool FilesystemNodeWINDOWS::
handle = FindFirstFile(toUnicode(searchPath), &desc);
if (handle == INVALID_HANDLE_VALUE)
if(handle == INVALID_HANDLE_VALUE)
return false;
addFile(myList, mode, _path.c_str(), &desc);
while (FindNextFile(handle, &desc))
while(FindNextFile(handle, &desc))
addFile(myList, mode, _path.c_str(), &desc);
FindClose(handle);
@ -299,14 +299,14 @@ bool FilesystemNodeWINDOWS::rename(const string& newfile)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFSNode* FilesystemNodeWINDOWS::getParent() const
{
if (!_isValid || _isPseudoRoot)
return 0;
if(!_isValid || _isPseudoRoot)
return nullptr;
FilesystemNodeWINDOWS* p = new FilesystemNodeWINDOWS();
if (_path.size() > 3)
if(_path.size() > 3)
{
const char *start = _path.c_str();
const char *end = lastPathComponent(_path);
const char* start = _path.c_str();
const char* end = lastPathComponent(_path);
p->_path = string(start, end - start);
p->_isValid = true;