Permalink
Browse files

Remove unnecessary pointer checks.

There are *no* more spacing issues. I used tabs exclusively.
Also, I made changes off of the develop branch.

Here's the Ruby regex that I used:
text.gsub!(/(( |\t)*)if ?\((.*)\) ?{?\n?( |\t)*(free ?\(|delete |delete\[\] )(.*)\)?;/, "\\1\\5\\6;")
  • Loading branch information...
ryanmjacobs committed Feb 15, 2015
1 parent b06af53 commit 55a30673c4c0331b4d0fc21eedbc7a9aea242efd
Showing with 141 additions and 266 deletions.
  1. +1 −2 src/Format.cpp
  2. +3 −3 src/Misc.cpp
  3. +27 −46 src/client/Client.cpp
  4. +15 −30 src/client/GameSave.cpp
  5. +5 −10 src/client/HTTP.cpp
  6. +2 −4 src/client/SaveFile.cpp
  7. +1 −2 src/client/SaveInfo.cpp
  8. +1 −2 src/client/requestbroker/APIRequest.cpp
  9. +1 −2 src/client/requestbroker/ImageRequest.cpp
  10. +1 −2 src/client/requestbroker/ThumbRenderRequest.cpp
  11. +1 −2 src/client/requestbroker/WebRequest.cpp
  12. +1 −2 src/gui/colourpicker/ColourPickerActivity.cpp
  13. +1 −2 src/gui/console/ConsoleController.cpp
  14. +1 −2 src/gui/dialogues/ConfirmPrompt.cpp
  15. +1 −2 src/gui/dialogues/ErrorMessage.cpp
  16. +1 −2 src/gui/dialogues/TextPrompt.cpp
  17. +1 −2 src/gui/filebrowser/FileBrowserActivity.cpp
  18. +2 −4 src/gui/game/BitmapBrush.h
  19. +4 −8 src/gui/game/Brush.h
  20. +1 −2 src/gui/game/EllipseBrush.h
  21. +1 −2 src/gui/game/GameController.cpp
  22. +10 −20 src/gui/game/GameModel.cpp
  23. +4 −8 src/gui/game/GameView.cpp
  24. +1 −2 src/gui/game/TriangleBrush.h
  25. +2 −4 src/gui/interface/Appearance.cpp
  26. +3 −6 src/gui/interface/AvatarButton.cpp
  27. +2 −4 src/gui/interface/Button.cpp
  28. +2 −4 src/gui/interface/Checkbox.cpp
  29. +1 −2 src/gui/interface/Component.cpp
  30. +1 −2 src/gui/interface/DropDown.cpp
  31. +2 −4 src/gui/interface/Engine.cpp
  32. +1 −2 src/gui/interface/Panel.cpp
  33. +5 −10 src/gui/interface/SaveButton.cpp
  34. +1 −2 src/gui/interface/Slider.cpp
  35. +2 −4 src/gui/interface/Textbox.cpp
  36. +1 −2 src/gui/localbrowser/LocalBrowserController.cpp
  37. +2 −4 src/gui/localbrowser/LocalBrowserModel.cpp
  38. +1 −2 src/gui/options/OptionsController.cpp
  39. +1 −2 src/gui/preview/PreviewController.cpp
  40. +4 −8 src/gui/preview/PreviewModel.cpp
  41. +2 −4 src/gui/preview/PreviewView.cpp
  42. +1 −2 src/gui/render/RenderController.cpp
  43. +3 −6 src/gui/save/LocalSaveActivity.cpp
  44. +4 −8 src/gui/save/ServerSaveActivity.cpp
  45. +3 −6 src/gui/search/SearchController.cpp
  46. +1 −2 src/gui/search/SearchModel.cpp
  47. +1 −2 src/gui/search/Thumbnail.cpp
  48. +1 −2 src/gui/tags/TagsController.cpp
  49. +1 −2 src/gui/update/UpdateActivity.cpp
  50. +4 −4 src/lua/LegacyLuaAPI.cpp
  51. +1 −1 src/simulation/CoordStack.h
  52. +1 −2 src/simulation/SaveRenderer.cpp
@@ -260,8 +260,7 @@ struct PNGChunk
}
~PNGChunk()
{
if (Data)
delete[] Data;
delete[] Data;
}
};
@@ -462,9 +462,9 @@ int register_extension()
returnval = 1;
finalise:
if(iconname) free(iconname);
if(opencommand) free(opencommand);
if(currentfilename) free(currentfilename);
free(iconname);
free(opencommand);
free(currentfilename);
return returnval;
#elif defined(LIN)
@@ -335,10 +335,10 @@ bool Client::DoInstallation()
returnval = 1;
finalise:
if(iconname) free(iconname);
if(opencommand) free(opencommand);
if(protocolcommand) free(protocolcommand);
if(currentfilename) free(currentfilename);
free(iconname);
free(opencommand);
free(protocolcommand);
free(currentfilename);
return returnval;
#elif defined(LIN)
@@ -673,8 +673,7 @@ void Client::Tick()
if(status != 200)
{
if(data)
free(data);
free(data);
}
else if(data)
{
@@ -760,8 +759,7 @@ void Client::Tick()
//Do nothing
}
if(data)
free(data);
free(data);
}
}
}
@@ -944,7 +942,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
{
if(strncmp((const char *)data, "OK", 2)!=0)
{
if(gameData) delete[] gameData;
delete[] gameData;
lastError = std::string((const char *)data);
free(data);
return RequestFailure;
@@ -965,14 +963,14 @@ RequestStatus Client::UploadSave(SaveInfo & save)
}
}
free(data);
if(gameData) delete[] gameData;
delete[] gameData;
return RequestOkay;
}
else if(data)
{
free(data);
}
if(gameData) delete[] gameData;
delete[] gameData;
return RequestFailure;
}
@@ -1392,8 +1390,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return LoginError;
}
@@ -1439,12 +1436,10 @@ RequestStatus Client::DeleteSave(int saveID)
lastError = http_ret_text(dataStatus);
goto failure;
}
if(data)
free(data);
free(data);
return RequestOkay;
failure:
if(data)
free(data);
free(data);
return RequestFailure;
}
@@ -1499,12 +1494,10 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
lastError = http_ret_text(dataStatus);
goto failure;
}
if(data)
free(data);
free(data);
return RequestOkay;
failure:
if(data)
free(data);
free(data);
return RequestFailure;
}
@@ -1555,12 +1548,10 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
lastError = http_ret_text(dataStatus);
goto failure;
}
if(data)
free(data);
free(data);
return RequestOkay;
failure:
if(data)
free(data);
free(data);
return RequestFailure;
}
@@ -1613,12 +1604,10 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
lastError = http_ret_text(dataStatus);
goto failure;
}
if(data)
free(data);
free(data);
return RequestOkay;
failure:
if(data)
free(data);
free(data);
return RequestFailure;
}
@@ -1667,12 +1656,10 @@ RequestStatus Client::UnpublishSave(int saveID)
lastError = http_ret_text(dataStatus);
goto failure;
}
if(data)
free(data);
free(data);
return RequestOkay;
failure:
if(data)
free(data);
free(data);
return RequestFailure;
}
@@ -1690,8 +1677,7 @@ RequestStatus Client::PublishSave(int saveID)
const char *const postDatas[] = { "" };
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);
if (data)
free(data);
free(data);
}
else
{
@@ -1787,7 +1773,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
}
else
{
if (data) free(data);
free(data);
lastError = http_ret_text(dataStatus);
}
return NULL;
@@ -2000,8 +1986,7 @@ std::vector<SaveComment*> * Client::GetComments(int saveID, int start, int count
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return commentArray;
}
@@ -2049,8 +2034,7 @@ std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return tagArray;
}
@@ -2132,8 +2116,7 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string q
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return saveArray;
}
@@ -2321,8 +2304,7 @@ std::list<std::string> * Client::RemoveTag(int saveID, std::string tag)
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return tags;
}
@@ -2382,8 +2364,7 @@ std::list<std::string> * Client::AddTag(int saveID, std::string tag)
{
lastError = http_ret_text(dataStatus);
}
if(data)
free(data);
free(data);
return tags;
}
@@ -1075,17 +1075,13 @@ void GameSave::readOPS(char * data, int dataLength)
fail:
//Clean up everything
bson_destroy(&b);
if(freeIndices)
free(freeIndices);
if(partsSimIndex)
free(partsSimIndex);
free(freeIndices);
free(partsSimIndex);
throw ParseException(ParseException::Corrupt, "Save data corrupt");
fin:
bson_destroy(&b);
if(freeIndices)
free(freeIndices);
if(partsSimIndex)
free(partsSimIndex);
free(freeIndices);
free(partsSimIndex);
}
void GameSave::readPSv(char * data, int dataLength)
@@ -2191,28 +2187,17 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
fin:
bson_destroy(&b);
if(partsData)
free(partsData);
if(wallData)
free(wallData);
if(fanData)
free(fanData);
if (elementCount)
delete[] elementCount;
if (partsSaveIndex)
free(partsSaveIndex);
if (soapLinkData)
free(soapLinkData);
if (partsPosData)
free(partsPosData);
if (partsPosFirstMap)
free(partsPosFirstMap);
if (partsPosLastMap)
free(partsPosLastMap);
if (partsPosCount)
free(partsPosCount);
if (partsPosLink)
free(partsPosLink);
free(partsData);
free(wallData);
free(fanData);
delete[] elementCount;
free(partsSaveIndex);
free(soapLinkData);
free(partsPosData);
free(partsPosFirstMap);
free(partsPosLastMap);
free(partsPosCount);
free(partsPosLink);
return (char*)outputData;
}
@@ -552,8 +552,7 @@ int http_async_req_status(void *ctx)
{
cx->tptr = 0;
cx->tlen = 0;
if (cx->tbuf)
free(cx->tbuf);
free(cx->tbuf);
cx->state = HTS_RECV;
}
cx->last = now;
@@ -679,11 +678,9 @@ void http_async_req_close(void *ctx)
{
cx->keep = 1;
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);
free(ctx);
}
@@ -1083,8 +1080,7 @@ char *http_multipart_post(const char *uri, const char *const *names, const char
return http_async_req_stop(ctx, ret, len);
fail:
if (data)
free(data);
free(data);
if (own_plen)
free(plens);
if (ret)
@@ -1273,8 +1269,7 @@ void *http_multipart_post_async(const char *uri, const char *const *names, const
return ctx;
fail:
if (data)
free(data);
free(data);
if (own_plen)
free(plens);
//if (ret)
@@ -65,9 +65,7 @@ void SaveFile::SetDisplayName(std::string displayName)
}
SaveFile::~SaveFile() {
if(gameSave)
delete gameSave;
if(thumbnail)
delete thumbnail;
delete gameSave;
delete thumbnail;
}
@@ -176,7 +176,6 @@ GameSave * SaveInfo::GetGameSave()
void SaveInfo::SetGameSave(GameSave * saveGame)
{
if(gameSave)
delete gameSave;
delete gameSave;
gameSave = saveGame;
}
@@ -61,8 +61,7 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
//#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
//#endif
if(data)
free(data);
free(data);
return RequestBroker::Failed;
}
@@ -76,8 +76,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
#endif
if(data)
free(data);
free(data);
return RequestBroker::Failed;
}
@@ -38,8 +38,7 @@ RequestBroker::ProcessResponse ThumbRenderRequest::Process(RequestBroker & rb)
ThumbRenderRequest::~ThumbRenderRequest()
{
if(Save)
delete Save;
delete Save;
}
void ThumbRenderRequest::Cleanup()
Oops, something went wrong.

0 comments on commit 55a3067

Please sign in to comment.