Merge pull request #247 from ryanmjacobs:fix_pointer_checks

This commit is contained in:
jacksonmj 2015-05-16 02:18:26 +01:00
commit 34567bc496
52 changed files with 141 additions and 266 deletions

View File

@ -260,7 +260,6 @@ struct PNGChunk
} }
~PNGChunk() ~PNGChunk()
{ {
if (Data)
delete[] Data; delete[] Data;
} }
}; };

View File

@ -462,9 +462,9 @@ int register_extension()
returnval = 1; returnval = 1;
finalise: finalise:
if(iconname) free(iconname); free(iconname);
if(opencommand) free(opencommand); free(opencommand);
if(currentfilename) free(currentfilename); free(currentfilename);
return returnval; return returnval;
#elif defined(LIN) #elif defined(LIN)

View File

@ -343,10 +343,10 @@ bool Client::DoInstallation()
returnval = 1; returnval = 1;
finalise: finalise:
if(iconname) free(iconname); free(iconname);
if(opencommand) free(opencommand); free(opencommand);
if(protocolcommand) free(protocolcommand); free(protocolcommand);
if(currentfilename) free(currentfilename); free(currentfilename);
return returnval; return returnval;
#elif defined(LIN) #elif defined(LIN)
@ -681,7 +681,6 @@ void Client::Tick()
if(status != 200) if(status != 200)
{ {
if(data)
free(data); free(data);
} }
else if(data) else if(data)
@ -768,7 +767,6 @@ void Client::Tick()
//Do nothing //Do nothing
} }
if(data)
free(data); free(data);
} }
} }
@ -952,7 +950,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
{ {
if(strncmp((const char *)data, "OK", 2)!=0) if(strncmp((const char *)data, "OK", 2)!=0)
{ {
if(gameData) delete[] gameData; delete[] gameData;
lastError = std::string((const char *)data); lastError = std::string((const char *)data);
free(data); free(data);
return RequestFailure; return RequestFailure;
@ -973,14 +971,14 @@ RequestStatus Client::UploadSave(SaveInfo & save)
} }
} }
free(data); free(data);
if(gameData) delete[] gameData; delete[] gameData;
return RequestOkay; return RequestOkay;
} }
else if(data) else if(data)
{ {
free(data); free(data);
} }
if(gameData) delete[] gameData; delete[] gameData;
return RequestFailure; return RequestFailure;
} }
@ -1400,7 +1398,6 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return LoginError; return LoginError;
} }
@ -1447,11 +1444,9 @@ RequestStatus Client::DeleteSave(int saveID)
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
goto failure; goto failure;
} }
if(data)
free(data); free(data);
return RequestOkay; return RequestOkay;
failure: failure:
if(data)
free(data); free(data);
return RequestFailure; return RequestFailure;
} }
@ -1507,11 +1502,9 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
goto failure; goto failure;
} }
if(data)
free(data); free(data);
return RequestOkay; return RequestOkay;
failure: failure:
if(data)
free(data); free(data);
return RequestFailure; return RequestFailure;
} }
@ -1563,11 +1556,9 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
goto failure; goto failure;
} }
if(data)
free(data); free(data);
return RequestOkay; return RequestOkay;
failure: failure:
if(data)
free(data); free(data);
return RequestFailure; return RequestFailure;
} }
@ -1621,11 +1612,9 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
goto failure; goto failure;
} }
if(data)
free(data); free(data);
return RequestOkay; return RequestOkay;
failure: failure:
if(data)
free(data); free(data);
return RequestFailure; return RequestFailure;
} }
@ -1675,11 +1664,9 @@ RequestStatus Client::UnpublishSave(int saveID)
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
goto failure; goto failure;
} }
if(data)
free(data); free(data);
return RequestOkay; return RequestOkay;
failure: failure:
if(data)
free(data); free(data);
return RequestFailure; return RequestFailure;
} }
@ -1698,7 +1685,6 @@ RequestStatus Client::PublishSave(int saveID)
const char *const postDatas[] = { "" }; const char *const postDatas[] = { "" };
size_t postLengths[] = { 1 }; size_t postLengths[] = { 1 };
char *data = http_multipart_post(urlStream.str().c_str(), postNames, postDatas, postLengths, userIDStream.str().c_str(), NULL, authUser.SessionID.c_str(), &dataStatus, NULL); char *data = http_multipart_post(urlStream.str().c_str(), postNames, postDatas, postLengths, userIDStream.str().c_str(), NULL, authUser.SessionID.c_str(), &dataStatus, NULL);
if (data)
free(data); free(data);
} }
else else
@ -1795,7 +1781,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
} }
else else
{ {
if (data) free(data); free(data);
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
return NULL; return NULL;
@ -2008,7 +1994,6 @@ std::vector<SaveComment*> * Client::GetComments(int saveID, int start, int count
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return commentArray; return commentArray;
} }
@ -2057,7 +2042,6 @@ std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return tagArray; return tagArray;
} }
@ -2140,7 +2124,6 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string q
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return saveArray; return saveArray;
} }
@ -2329,7 +2312,6 @@ std::list<std::string> * Client::RemoveTag(int saveID, std::string tag)
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return tags; return tags;
} }
@ -2390,7 +2372,6 @@ std::list<std::string> * Client::AddTag(int saveID, std::string tag)
{ {
lastError = http_ret_text(dataStatus); lastError = http_ret_text(dataStatus);
} }
if(data)
free(data); free(data);
return tags; return tags;
} }

View File

@ -1075,16 +1075,12 @@ void GameSave::readOPS(char * data, int dataLength)
fail: fail:
//Clean up everything //Clean up everything
bson_destroy(&b); bson_destroy(&b);
if(freeIndices)
free(freeIndices); free(freeIndices);
if(partsSimIndex)
free(partsSimIndex); free(partsSimIndex);
throw ParseException(ParseException::Corrupt, "Save data corrupt"); throw ParseException(ParseException::Corrupt, "Save data corrupt");
fin: fin:
bson_destroy(&b); bson_destroy(&b);
if(freeIndices)
free(freeIndices); free(freeIndices);
if(partsSimIndex)
free(partsSimIndex); free(partsSimIndex);
} }
@ -2191,27 +2187,16 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
fin: fin:
bson_destroy(&b); bson_destroy(&b);
if(partsData)
free(partsData); free(partsData);
if(wallData)
free(wallData); free(wallData);
if(fanData)
free(fanData); free(fanData);
if (elementCount)
delete[] elementCount; delete[] elementCount;
if (partsSaveIndex)
free(partsSaveIndex); free(partsSaveIndex);
if (soapLinkData)
free(soapLinkData); free(soapLinkData);
if (partsPosData)
free(partsPosData); free(partsPosData);
if (partsPosFirstMap)
free(partsPosFirstMap); free(partsPosFirstMap);
if (partsPosLastMap)
free(partsPosLastMap); free(partsPosLastMap);
if (partsPosCount)
free(partsPosCount); free(partsPosCount);
if (partsPosLink)
free(partsPosLink); free(partsPosLink);
return (char*)outputData; return (char*)outputData;

View File

@ -557,7 +557,6 @@ int http_async_req_status(void *ctx)
{ {
cx->tptr = 0; cx->tptr = 0;
cx->tlen = 0; cx->tlen = 0;
if (cx->tbuf)
free(cx->tbuf); free(cx->tbuf);
cx->state = HTS_RECV; cx->state = HTS_RECV;
} }
@ -684,10 +683,8 @@ void http_async_req_close(void *ctx)
{ {
cx->keep = 1; cx->keep = 1;
tmp = http_async_req_stop(ctx, NULL, NULL); tmp = http_async_req_stop(ctx, NULL, NULL);
if (tmp)
free(tmp); free(tmp);
} }
if (cx->fdhost)
free(cx->fdhost); free(cx->fdhost);
PCLOSE(cx->fd); PCLOSE(cx->fd);
free(ctx); free(ctx);
@ -1088,7 +1085,6 @@ retry:
return http_async_req_stop(ctx, ret, len); return http_async_req_stop(ctx, ret, len);
fail: fail:
if (data)
free(data); free(data);
if (own_plen) if (own_plen)
free(plens); free(plens);
@ -1278,7 +1274,6 @@ retry:
return ctx; return ctx;
fail: fail:
if (data)
free(data); free(data);
if (own_plen) if (own_plen)
free(plens); free(plens);

View File

@ -65,9 +65,7 @@ void SaveFile::SetDisplayName(std::string displayName)
} }
SaveFile::~SaveFile() { SaveFile::~SaveFile() {
if(gameSave)
delete gameSave; delete gameSave;
if(thumbnail)
delete thumbnail; delete thumbnail;
} }

View File

@ -176,7 +176,6 @@ GameSave * SaveInfo::GetGameSave()
void SaveInfo::SetGameSave(GameSave * saveGame) void SaveInfo::SetGameSave(GameSave * saveGame)
{ {
if(gameSave)
delete gameSave; delete gameSave;
gameSave = saveGame; gameSave = saveGame;
} }

View File

@ -61,7 +61,6 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
//#ifdef DEBUG //#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl; std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
//#endif //#endif
if(data)
free(data); free(data);
return RequestBroker::Failed; return RequestBroker::Failed;

View File

@ -76,7 +76,6 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
#ifdef DEBUG #ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl; std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
#endif #endif
if(data)
free(data); free(data);
return RequestBroker::Failed; return RequestBroker::Failed;

View File

@ -38,7 +38,6 @@ RequestBroker::ProcessResponse ThumbRenderRequest::Process(RequestBroker & rb)
ThumbRenderRequest::~ThumbRenderRequest() ThumbRenderRequest::~ThumbRenderRequest()
{ {
if(Save)
delete Save; delete Save;
} }

View File

@ -60,7 +60,6 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
//#ifdef DEBUG //#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl; std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
//#endif //#endif
if(data)
free(data); free(data);
return RequestBroker::Failed; return RequestBroker::Failed;

View File

@ -317,7 +317,6 @@ void ColourPickerActivity::OnDraw()
} }
ColourPickerActivity::~ColourPickerActivity() { ColourPickerActivity::~ColourPickerActivity() {
if(callback)
delete callback; delete callback;
} }

View File

@ -68,7 +68,6 @@ ConsoleView * ConsoleController::GetView()
ConsoleController::~ConsoleController() { ConsoleController::~ConsoleController() {
if(ui::Engine::Ref().GetWindow() == consoleView) if(ui::Engine::Ref().GetWindow() == consoleView)
ui::Engine::Ref().CloseWindow(); ui::Engine::Ref().CloseWindow();
if(callback)
delete callback; delete callback;
delete consoleModel; delete consoleModel;
delete consoleView; delete consoleView;

View File

@ -144,7 +144,6 @@ void ConfirmPrompt::OnDraw()
} }
ConfirmPrompt::~ConfirmPrompt() { ConfirmPrompt::~ConfirmPrompt() {
if(callback)
delete callback; delete callback;
} }

View File

@ -72,7 +72,6 @@ void ErrorMessage::OnDraw()
} }
ErrorMessage::~ErrorMessage() { ErrorMessage::~ErrorMessage() {
if(callback)
delete callback; delete callback;
} }

View File

@ -108,7 +108,6 @@ void TextPrompt::OnDraw()
} }
TextPrompt::~TextPrompt() { TextPrompt::~TextPrompt() {
if(callback)
delete callback; delete callback;
} }

View File

@ -332,6 +332,5 @@ void FileBrowserActivity::OnDraw()
FileBrowserActivity::~FileBrowserActivity() FileBrowserActivity::~FileBrowserActivity()
{ {
if(callback)
delete callback; delete callback;
} }

View File

@ -51,7 +51,6 @@ public:
{ {
if(origBitmap) if(origBitmap)
{ {
if(bitmap)
delete[] bitmap; delete[] bitmap;
bitmap = new unsigned char[size.X*size.Y]; bitmap = new unsigned char[size.X*size.Y];
if(size == origSize) if(size == origSize)
@ -88,7 +87,6 @@ public:
} }
virtual ~BitmapBrush() virtual ~BitmapBrush()
{ {
if(origBitmap)
delete[] origBitmap; delete[] origBitmap;
} }
}; };

View File

@ -18,7 +18,6 @@ protected:
GenerateBitmap(); GenerateBitmap();
if(!bitmap) if(!bitmap)
return; return;
if(outline)
delete[] outline; delete[] outline;
outline = new unsigned char[size.X*size.Y]; outline = new unsigned char[size.X*size.Y];
for(int x = 0; x < size.X; x++) for(int x = 0; x < size.X; x++)
@ -64,9 +63,7 @@ public:
updateOutline(); updateOutline();
} }
virtual ~Brush() { virtual ~Brush() {
if(bitmap)
delete[] bitmap; delete[] bitmap;
if(outline)
delete[] outline; delete[] outline;
} }
virtual void RenderRect(Renderer * ren, ui::Point position1, ui::Point position2); virtual void RenderRect(Renderer * ren, ui::Point position1, ui::Point position2);
@ -75,7 +72,6 @@ public:
virtual void RenderFill(Renderer * ren, ui::Point position); virtual void RenderFill(Renderer * ren, ui::Point position);
virtual void GenerateBitmap() virtual void GenerateBitmap()
{ {
if(bitmap)
delete[] bitmap; delete[] bitmap;
bitmap = new unsigned char[size.X*size.Y]; bitmap = new unsigned char[size.X*size.Y];
for(int x = 0; x < size.X; x++) for(int x = 0; x < size.X; x++)

View File

@ -14,7 +14,6 @@ public:
} }
virtual void GenerateBitmap() virtual void GenerateBitmap()
{ {
if(bitmap)
delete[] bitmap; delete[] bitmap;
bitmap = new unsigned char[size.X*size.Y]; bitmap = new unsigned char[size.X*size.Y];
int rx = radius.X; int rx = radius.X;

View File

@ -1223,7 +1223,6 @@ void GameController::OpenTags()
{ {
if(gameModel->GetSave() && gameModel->GetSave()->GetID()) if(gameModel->GetSave() && gameModel->GetSave()->GetID())
{ {
if (tagsWindow)
delete tagsWindow; delete tagsWindow;
tagsWindow = new TagsController(new TagsCallback(this), gameModel->GetSave()); tagsWindow = new TagsController(new TagsCallback(this), gameModel->GetSave());
ui::Engine::Ref().ShowWindow(tagsWindow->GetView()); ui::Engine::Ref().ShowWindow(tagsWindow->GetView());

View File

@ -176,13 +176,9 @@ GameModel::~GameModel()
} }
delete sim; delete sim;
delete ren; delete ren;
if(placeSave)
delete placeSave; delete placeSave;
if(clipboard)
delete clipboard; delete clipboard;
if(currentSave)
delete currentSave; delete currentSave;
if(currentFile)
delete currentFile; delete currentFile;
//if(activeTools) //if(activeTools)
// delete[] activeTools; // delete[] activeTools;
@ -556,14 +552,12 @@ void GameModel::SetSave(SaveInfo * newSave)
{ {
if(currentSave != newSave) if(currentSave != newSave)
{ {
if(currentSave)
delete currentSave; delete currentSave;
if(newSave == NULL) if(newSave == NULL)
currentSave = NULL; currentSave = NULL;
else else
currentSave = new SaveInfo(*newSave); currentSave = new SaveInfo(*newSave);
} }
if(currentFile)
delete currentFile; delete currentFile;
currentFile = NULL; currentFile = NULL;
@ -599,14 +593,12 @@ void GameModel::SetSaveFile(SaveFile * newSave)
{ {
if(currentFile != newSave) if(currentFile != newSave)
{ {
if(currentFile)
delete currentFile; delete currentFile;
if(newSave == NULL) if(newSave == NULL)
currentFile = NULL; currentFile = NULL;
else else
currentFile = new SaveFile(*newSave); currentFile = new SaveFile(*newSave);
} }
if (currentSave)
delete currentSave; delete currentSave;
currentSave = NULL; currentSave = NULL;
@ -907,7 +899,6 @@ void GameModel::SetPlaceSave(GameSave * save)
{ {
if(save != placeSave) if(save != placeSave)
{ {
if(placeSave)
delete placeSave; delete placeSave;
if(save) if(save)
placeSave = new GameSave(*save); placeSave = new GameSave(*save);
@ -919,7 +910,6 @@ void GameModel::SetPlaceSave(GameSave * save)
void GameModel::SetClipboard(GameSave * save) void GameModel::SetClipboard(GameSave * save)
{ {
if(clipboard)
delete clipboard; delete clipboard;
clipboard = save; clipboard = save;
} }

View File

@ -142,7 +142,6 @@ public:
} }
virtual ~SplitButton() virtual ~SplitButton()
{ {
if(splitActionCallback)
delete splitActionCallback; delete splitActionCallback;
} }
}; };
@ -460,7 +459,6 @@ GameView::~GameView()
} }
if(placeSaveThumb)
delete placeSaveThumb; delete placeSaveThumb;
} }
@ -728,7 +726,6 @@ void GameView::NotifyToolListChanged(GameModel * sender)
tempButton->SetActionCallback(new ToolAction(this, toolList[i])); tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
tempButton->Appearance.SetTexture(tempTexture); tempButton->Appearance.SetTexture(tempTexture);
if(tempTexture)
delete tempTexture; delete tempTexture;
tempButton->Appearance.BackgroundInactive = ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue); tempButton->Appearance.BackgroundInactive = ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue);
@ -1867,7 +1864,6 @@ void GameView::NotifyLogChanged(GameModel * sender, string entry)
void GameView::NotifyPlaceSaveChanged(GameModel * sender) void GameView::NotifyPlaceSaveChanged(GameModel * sender)
{ {
if(placeSaveThumb)
delete placeSaveThumb; delete placeSaveThumb;
if(sender->GetPlaceSave()) if(sender->GetPlaceSave())
{ {

View File

@ -21,7 +21,6 @@ public:
}; };
virtual void GenerateBitmap() virtual void GenerateBitmap()
{ {
if(bitmap)
delete[] bitmap; delete[] bitmap;
bitmap = new unsigned char[size.X*size.Y]; bitmap = new unsigned char[size.X*size.Y];
int rx = radius.X; int rx = radius.X;

View File

@ -37,7 +37,6 @@ namespace ui
void Appearance::SetTexture(VideoBuffer * texture) void Appearance::SetTexture(VideoBuffer * texture)
{ {
if(this->texture)
delete this->texture; delete this->texture;
if(texture) if(texture)
this->texture = new VideoBuffer(texture); this->texture = new VideoBuffer(texture);
@ -47,7 +46,6 @@ namespace ui
Appearance::~Appearance() Appearance::~Appearance()
{ {
if(texture)
delete texture; delete texture;
} }

View File

@ -25,9 +25,7 @@ AvatarButton::AvatarButton(Point position, Point size, std::string username):
AvatarButton::~AvatarButton() AvatarButton::~AvatarButton()
{ {
RequestBroker::Ref().DetachRequestListener(this); RequestBroker::Ref().DetachRequestListener(this);
if(avatar)
delete avatar; delete avatar;
if(actionCallback)
delete actionCallback; delete actionCallback;
} }
@ -45,7 +43,6 @@ void AvatarButton::OnResponseReady(void * imagePtr, int identifier)
VideoBuffer * image = (VideoBuffer*)imagePtr; VideoBuffer * image = (VideoBuffer*)imagePtr;
if(image) if(image)
{ {
if(avatar)
delete avatar; delete avatar;
avatar = image; avatar = image;
} }

View File

@ -219,14 +219,12 @@ void Button::DoAltAction()
void Button::SetActionCallback(ButtonAction * action) void Button::SetActionCallback(ButtonAction * action)
{ {
if(actionCallback)
delete actionCallback; delete actionCallback;
actionCallback = action; actionCallback = action;
} }
Button::~Button() Button::~Button()
{ {
if(actionCallback)
delete actionCallback; delete actionCallback;
} }

View File

@ -96,13 +96,11 @@ void Checkbox::Draw(const Point& screenPos)
void Checkbox::SetActionCallback(CheckboxAction * action) void Checkbox::SetActionCallback(CheckboxAction * action)
{ {
if(actionCallback)
delete actionCallback; delete actionCallback;
actionCallback = action; actionCallback = action;
} }
Checkbox::~Checkbox() { Checkbox::~Checkbox() {
if(actionCallback)
delete actionCallback; delete actionCallback;
} }

View File

@ -239,6 +239,5 @@ void Component::OnMouseWheelInside(int localx, int localy, int d)
Component::~Component() Component::~Component()
{ {
if(menu)
delete menu; delete menu;
} }

View File

@ -190,7 +190,6 @@ void DropDown::OnMouseLeave(int x, int y)
DropDown::~DropDown() { DropDown::~DropDown() {
if(callback)
delete callback; delete callback;
} }

View File

@ -39,7 +39,6 @@ Engine::Engine():
Engine::~Engine() Engine::~Engine()
{ {
if(state_ != NULL)
delete state_; delete state_;
//Dispose of any Windows. //Dispose of any Windows.
while(!windows.empty()) while(!windows.empty())
@ -47,7 +46,6 @@ Engine::~Engine()
delete windows.top(); delete windows.top();
windows.pop(); windows.pop();
} }
if (lastBuffer)
free(lastBuffer); free(lastBuffer);
} }

View File

@ -46,7 +46,6 @@ Panel::~Panel()
{ {
for(unsigned i = 0; i < children.size(); ++i) for(unsigned i = 0; i < children.size(); ++i)
{ {
if( children[i] )
delete children[i]; delete children[i];
} }
#ifdef OGLI #ifdef OGLI

View File

@ -118,13 +118,9 @@ SaveButton::~SaveButton()
{ {
RequestBroker::Ref().DetachRequestListener(this); RequestBroker::Ref().DetachRequestListener(this);
if(thumbnail)
delete thumbnail; delete thumbnail;
if(actionCallback)
delete actionCallback; delete actionCallback;
if(save)
delete save; delete save;
if(file)
delete file; delete file;
} }
@ -133,7 +129,6 @@ void SaveButton::OnResponseReady(void * imagePtr, int identifier)
VideoBuffer * image = (VideoBuffer*)imagePtr; VideoBuffer * image = (VideoBuffer*)imagePtr;
if(image) if(image)
{ {
if(thumbnail)
delete thumbnail; delete thumbnail;
thumbnail = image; thumbnail = image;
waitingForThumb = false; waitingForThumb = false;

View File

@ -68,7 +68,6 @@ void Slider::SetColour(Colour col1, Colour col2)
{ {
pixel pix[2] = {(pixel)PIXRGB(col1.Red, col1.Green, col1.Blue), (pixel)PIXRGB(col2.Red, col2.Green, col2.Blue)}; pixel pix[2] = {(pixel)PIXRGB(col1.Red, col1.Green, col1.Blue), (pixel)PIXRGB(col2.Red, col2.Green, col2.Blue)};
float fl[2] = {0.0f, 1.0f}; float fl[2] = {0.0f, 1.0f};
if(bgGradient)
free(bgGradient); free(bgGradient);
this->col1 = col1; this->col1 = col1;
this->col2 = col2; this->col2 = col2;

View File

@ -35,7 +35,6 @@ Textbox::Textbox(Point position, Point size, std::string textboxText, std::strin
Textbox::~Textbox() Textbox::~Textbox()
{ {
if(actionCallback)
delete actionCallback; delete actionCallback;
} }
@ -566,7 +565,6 @@ Textbox::Textbox(Point position, Point size, std::string textboxText):
Textbox::~Textbox() Textbox::~Textbox()
{ {
if(actionCallback)
delete actionCallback; delete actionCallback;
} }

View File

@ -176,7 +176,6 @@ void LocalBrowserController::Exit()
LocalBrowserController::~LocalBrowserController() { LocalBrowserController::~LocalBrowserController() {
if(ui::Engine::Ref().GetWindow() == browserView) if(ui::Engine::Ref().GetWindow() == browserView)
ui::Engine::Ref().CloseWindow(); ui::Engine::Ref().CloseWindow();
if(callback)
delete callback; delete callback;
delete browserModel; delete browserModel;
delete browserView; delete browserView;

View File

@ -50,7 +50,6 @@ SaveFile * LocalBrowserModel::GetSave()
void LocalBrowserModel::SetSave(SaveFile * newStamp) void LocalBrowserModel::SetSave(SaveFile * newStamp)
{ {
if(stamp)
delete stamp; delete stamp;
stamp = new SaveFile(*newStamp); stamp = new SaveFile(*newStamp);
} }
@ -141,7 +140,6 @@ void LocalBrowserModel::notifySelectedChanged()
} }
LocalBrowserModel::~LocalBrowserModel() { LocalBrowserModel::~LocalBrowserModel() {
if(stamp)
delete stamp; delete stamp;
} }

View File

@ -105,7 +105,6 @@ OptionsController::~OptionsController() {
} }
delete model; delete model;
delete view; delete view;
if(callback)
delete callback; delete callback;
} }

View File

@ -192,7 +192,6 @@ PreviewController::~PreviewController() {
Client::Ref().RemoveListener(this); Client::Ref().RemoveListener(this);
delete previewModel; delete previewModel;
delete previewView; delete previewView;
if(callback)
delete callback; delete callback;
} }

View File

@ -139,13 +139,11 @@ void PreviewModel::OnResponseReady(void * object, int identifier)
{ {
if (identifier == 1) if (identifier == 1)
{ {
if (saveData)
delete saveData; delete saveData;
saveData = (std::vector<unsigned char>*)object; saveData = (std::vector<unsigned char>*)object;
} }
if (identifier == 2) if (identifier == 2)
{ {
if (save)
delete save; delete save;
save = (SaveInfo*)object; save = (SaveInfo*)object;
} }
@ -243,9 +241,7 @@ void PreviewModel::AddObserver(PreviewView * observer)
PreviewModel::~PreviewModel() PreviewModel::~PreviewModel()
{ {
RequestBroker::Ref().DetachRequestListener(this); RequestBroker::Ref().DetachRequestListener(this);
if (save)
delete save; delete save;
if (saveData)
delete saveData; delete saveData;
if (saveComments) if (saveComments)
{ {

View File

@ -408,7 +408,6 @@ void PreviewView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
void PreviewView::NotifySaveChanged(PreviewModel * sender) void PreviewView::NotifySaveChanged(PreviewModel * sender)
{ {
SaveInfo * save = sender->GetSave(); SaveInfo * save = sender->GetSave();
if(savePreview)
delete savePreview; delete savePreview;
savePreview = NULL; savePreview = NULL;
if(save) if(save)
@ -624,7 +623,6 @@ PreviewView::~PreviewView()
RemoveComponent(submitCommentButton); RemoveComponent(submitCommentButton);
delete submitCommentButton; delete submitCommentButton;
} }
if(savePreview)
delete savePreview; delete savePreview;
} }

View File

@ -59,7 +59,6 @@ RenderController::~RenderController() {
{ {
ui::Engine::Ref().CloseWindow(); ui::Engine::Ref().CloseWindow();
} }
if(callback)
delete callback; delete callback;
delete renderModel; delete renderModel;
delete renderView; delete renderView;

View File

@ -135,7 +135,6 @@ void LocalSaveActivity::OnDraw()
void LocalSaveActivity::OnResponseReady(void * imagePtr, int identifier) void LocalSaveActivity::OnResponseReady(void * imagePtr, int identifier)
{ {
if(thumbnail)
delete thumbnail; delete thumbnail;
thumbnail = (VideoBuffer*)imagePtr; thumbnail = (VideoBuffer*)imagePtr;
} }
@ -143,8 +142,6 @@ void LocalSaveActivity::OnResponseReady(void * imagePtr, int identifier)
LocalSaveActivity::~LocalSaveActivity() LocalSaveActivity::~LocalSaveActivity()
{ {
RequestBroker::Ref().DetachRequestListener(this); RequestBroker::Ref().DetachRequestListener(this);
if(thumbnail)
delete thumbnail; delete thumbnail;
if(callback)
delete callback; delete callback;
} }

View File

@ -358,7 +358,6 @@ void ServerSaveActivity::OnDraw()
void ServerSaveActivity::OnResponseReady(void * imagePtr, int identifier) void ServerSaveActivity::OnResponseReady(void * imagePtr, int identifier)
{ {
if(thumbnail)
delete thumbnail; delete thumbnail;
thumbnail = (VideoBuffer *)imagePtr; thumbnail = (VideoBuffer *)imagePtr;
} }
@ -366,10 +365,7 @@ void ServerSaveActivity::OnResponseReady(void * imagePtr, int identifier)
ServerSaveActivity::~ServerSaveActivity() ServerSaveActivity::~ServerSaveActivity()
{ {
RequestBroker::Ref().DetachRequestListener(this); RequestBroker::Ref().DetachRequestListener(this);
if(saveUploadTask)
delete saveUploadTask; delete saveUploadTask;
if(callback)
delete callback; delete callback;
if(thumbnail)
delete thumbnail; delete thumbnail;
} }

View File

@ -99,7 +99,6 @@ void SearchController::Exit()
SearchController::~SearchController() SearchController::~SearchController()
{ {
if(activePreview)
delete activePreview; delete activePreview;
if(ui::Engine::Ref().GetWindow() == searchView) if(ui::Engine::Ref().GetWindow() == searchView)
{ {
@ -204,7 +203,6 @@ void SearchController::InstantOpen(bool instant)
void SearchController::OpenSave(int saveID) void SearchController::OpenSave(int saveID)
{ {
if(activePreview)
delete activePreview; delete activePreview;
Graphics * g = ui::Engine::Ref().g; Graphics * g = ui::Engine::Ref().g;
g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
@ -214,7 +212,6 @@ void SearchController::OpenSave(int saveID)
void SearchController::OpenSave(int saveID, int saveDate) void SearchController::OpenSave(int saveID, int saveDate)
{ {
if(activePreview)
delete activePreview; delete activePreview;
Graphics * g = ui::Engine::Ref().g; Graphics * g = ui::Engine::Ref().g;
g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable

View File

@ -278,6 +278,5 @@ void SearchModel::notifySelectedChanged()
SearchModel::~SearchModel() SearchModel::~SearchModel()
{ {
if (loadedSave)
delete loadedSave; delete loadedSave;
} }

View File

@ -68,6 +68,5 @@ void Thumbnail::Resize(ui::Point newSize)
Thumbnail::~Thumbnail() Thumbnail::~Thumbnail()
{ {
if(Data)
delete[] Data; delete[] Data;
} }

View File

@ -47,7 +47,6 @@ TagsController::~TagsController() {
ui::Engine::Ref().CloseWindow(); ui::Engine::Ref().CloseWindow();
delete tagsModel; delete tagsModel;
delete tagsView; delete tagsView;
if(callback)
delete callback; delete callback;
} }

View File

@ -42,7 +42,6 @@ private:
data = http_async_req_stop(request, &status, &dataLength); data = http_async_req_stop(request, &status, &dataLength);
if (status!=200) if (status!=200)
{ {
if (data)
free(data); free(data);
errorStream << "Server responded with Status " << status; errorStream << "Server responded with Status " << status;
notifyError("Could not download update"); notifyError("Could not download update");

View File

@ -1944,10 +1944,10 @@ int luatpt_getscript(lua_State* l)
} }
fin: fin:
if(filedata) free(filedata); free(filedata);
if(fileuri) delete[] fileuri; delete[] fileuri;
if(filename) delete[] filename; delete[] filename;
if(luacommand) delete[] luacommand; delete[] luacommand;
luacommand = NULL; luacommand = NULL;
if(lastError) if(lastError)

View File

@ -45,7 +45,7 @@ public:
} }
~CoordStack() ~CoordStack()
{ {
if (stack) free(stack); free(stack);
} }
void push(int x, int y) void push(int x, int y)
{ {

View File

@ -140,7 +140,6 @@ VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire)
src+=WINDOWW; src+=WINDOWW;
} }
tempThumb = new VideoBuffer(pData, width*CELL, height*CELL); tempThumb = new VideoBuffer(pData, width*CELL, height*CELL);
if(pData)
free(pData); free(pData);
#endif #endif
} }