Mass replace NULL --> nullptr

(Except one instance was instead replaced with nil)
This commit is contained in:
2015-09-13 10:50:21 -04:00
parent f1b097a54c
commit 780b413d0c
24 changed files with 92 additions and 92 deletions

View File

@@ -14,12 +14,12 @@
extern cursor_type current_cursor;
static NSImage* imageFromURL(CFURLRef url){
CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, NULL);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, nullptr);
CGImageRef theImage = nil;
if(imageSource == nil) return nil;
theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr);
if(theImage == nil) return nil;
CFRelease( imageSource );
@@ -44,8 +44,8 @@ static NSImage* imageFromURL(CFURLRef url){
Cursor::Cursor(fs::path path, float hotSpotX, float hotSpotY){
FSRef ref;
FSPathMakeRef((UInt8*)path.c_str(), &ref, NULL);
CFURLRef imgPath = CFURLCreateFromFSRef(NULL, &ref);
FSPathMakeRef((UInt8*)path.c_str(), &ref, nullptr);
CFURLRef imgPath = CFURLCreateFromFSRef(nullptr, &ref);
NSImage *img = imageFromURL(imgPath);
NSCursor *cursor = [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(hotSpotX, hotSpotY)];

View File

@@ -53,7 +53,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
// but if the first flag is 0x0B0E, we have a new-format save
// the three flags still follow that.
FILE* file_id = fopen(file_to_load.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError("Loading Blades of Exile save file failed.");
return false;
}

View File

@@ -123,7 +123,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head
legacy::scen_item_data_type *item_data = new legacy::scen_item_data_type;
// TODO: Convert this (and all the others in this file) to use C++ streams
FILE* file_id = fopen(file_to_load.string().c_str(),"rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file.", get_file_error());
return false;
}
@@ -2164,7 +2164,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
legacy::tiny_tr_type tiny_t;
FILE* file_id = fopen(scen_file.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file for reading town data.", get_file_error());
return false;
}
@@ -2302,7 +2302,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
legacy::outdoor_record_type store_out;
FILE* file_id = fopen(scen_file.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file for reading outdoor data.", get_file_error());
return false;
}

View File

@@ -404,8 +404,8 @@ graf_pos cCustomGraphics::find_graphic(pic_num_t which_rect, bool party) {
}
size_t cCustomGraphics::count(bool party) {
if(!party && sheets == NULL) return 0;
else if(party && party_sheet == NULL) return 0;
if(!party && sheets == nullptr) return 0;
else if(party && party_sheet == nullptr) return 0;
else if(is_old || party) {
rectangle bounds(party ? *party_sheet : sheets[0]);
if(bounds.width() < 280) return bounds.width() / 28;

View File

@@ -65,12 +65,12 @@ using hilite_t = std::pair<size_t,size_t>;
struct cCustomGraphics {
size_t numSheets;
sf::Texture* sheets = NULL;
sf::Texture* sheets = nullptr;
std::shared_ptr<sf::Texture> party_sheet;
bool is_old = false;
void clear() {
if(sheets != NULL) delete[] sheets;
sheets = NULL;
if(sheets != nullptr) delete[] sheets;
sheets = nullptr;
}
~cCustomGraphics() {
clear();

View File

@@ -459,8 +459,8 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) {
// TODO: There's no way around it; I'll have to read resource files for this section.
FSRef file;
ResFileRefNum custRef;
OSErr err = FSPathMakeRef((const UInt8*)gpath.c_str(), &file, NULL);
err = FSOpenResourceFile(&file, 0, NULL, fsRdPerm, &custRef);
OSErr err = FSPathMakeRef((const UInt8*)gpath.c_str(), &file, nullptr);
err = FSOpenResourceFile(&file, 0, nullptr, fsRdPerm, &custRef);
if(err != noErr) { // TODO: Is the error that would be returned if the resources were stored in the resource fork?
HFSUniStr255 rsrc;
err = FSGetResourceForkName(&rsrc);
@@ -482,29 +482,29 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) {
showError("An old-style .meg graphics file was found, but it did not contain a PICT resource of ID 1.",noGraphics);
return false;
}
if(resHandle == NULL) {
if(resHandle == nullptr) {
CloseResFile(custRef);
showError("An old-style .meg graphics file was found, but an error occurred while fetching the PICT resource of ID 1.",noGraphics);
return false;
}
unsigned char* data = NULL;
unsigned char* data = nullptr;
int error = 0;
rectangle picFrame;
try {
picFrame = loadFromPictResource(resHandle, data, error);
} catch(std::runtime_error&) {
CloseResFile(custRef);
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
showError("An old-style .meg graphics file was found, but an error occurred while loading the PICT resource of ID 1.",noGraphics);
return false;
}
CloseResFile(custRef);
if(picFrame.width() <= 0 || picFrame.height() <= 0) {
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
showError("An old-style .meg graphics file was found, but an error occurred while reading it: " + errStrings[error],noGraphics);
return false;
}
graphics_store.create(picFrame.width(), picFrame.height(), data);
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
return true;
}

View File

@@ -31,7 +31,7 @@ tarball::header_posix_ustar tarball::generateTarHeader(const std::string& fileNa
// leave uid filled with NULs
// leave gid filled with NULs
snprintf(header.size,12,"%011llo",fileSize);
snprintf(header.mtime,12,"%011lo",time(NULL));
snprintf(header.mtime,12,"%011lo",time(nullptr));
memset(header.checksum,' ',8);
header.typeflag[0] = directory ? '5' : '0';
// leave linkname filled with NULs

View File

@@ -324,7 +324,7 @@ sf::Image* sfImageFromNSImage(NSImage *image) {
return nil;
NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
initWithBitmapDataPlanes: nil
pixelsWide: width
pixelsHigh: height
bitsPerSample: 8