Skip to content

Commit

Permalink
Get rid of C-style NULL throughout the code in favour of the less a…
Browse files Browse the repository at this point in the history
…mbiguous C++11-style `nullptr`.
  • Loading branch information
c-lipka committed Sep 12, 2018
1 parent 72cf1a7 commit 917a876
Show file tree
Hide file tree
Showing 147 changed files with 2,282 additions and 2,224 deletions.
6 changes: 3 additions & 3 deletions platform/unix/syspovtimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -76,7 +76,7 @@ void Delay(unsigned int msec)
timespec ts;
ts.tv_sec = msec / 1000;
ts.tv_nsec = (POV_ULONG) (1000000) * (msec % 1000);
nanosleep(&ts, NULL);
nanosleep(&ts, nullptr);
#elif defined(HAVE_USLEEP)
POV_ASSERT(msec < 1000); // On some systems, usleep() does not support sleeping for 1 second or more.
usleep (msec * (useconds_t)1000);
Expand Down Expand Up @@ -126,7 +126,7 @@ static inline bool GettimeofdayMillisec(POV_ULONG& result)
{
#if defined(HAVE_GETTIMEOFDAY)
struct timeval tv; // seconds + microseconds since
bool success = (gettimeofday(&tv, NULL) == 0);
bool success = (gettimeofday(&tv, nullptr) == 0);
if (success)
result = static_cast<POV_ULONG>(tv.tv_sec) *1000
+ static_cast<POV_ULONG>(tv.tv_usec) /1000;
Expand Down
8 changes: 4 additions & 4 deletions platform/windows/syspovtimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -65,7 +65,7 @@ Timer::Timer () :
// TODO - sources on the internet indicate that GetThreadTimes() and GetProcessTimes() have been
// around as early as NT 3.1. Is there a reason we're only making use of it in NT 4.0 and
// later Windows versions?
mThreadHandle (NULL),
mThreadHandle (nullptr),
mCPUTimeSupported (WindowsVersionDetector().IsNTVersion (4,0))
{
if (mCPUTimeSupported)
Expand All @@ -74,15 +74,15 @@ Timer::Timer () :
&mThreadHandle, 0, TRUE, DUPLICATE_SAME_ACCESS))
{
POV_ASSERT (false);
mThreadHandle = NULL;
mThreadHandle = nullptr;
}
}
Reset ();
}

Timer::~Timer ()
{
if (mThreadHandle != NULL)
if (mThreadHandle != nullptr)
CloseHandle (mThreadHandle);
}

Expand Down
6 changes: 3 additions & 3 deletions platform/x86/cpuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -159,7 +159,7 @@ CPUVendorInfo gCPUVendorInfo[] = {
{ kCPUVendor_VM, "VMwareVMware" }, // VMWare
{ kCPUVendor_VM, "XenVMMXenVMM" }, // Xen HVM
// End of list.
{ kCPUVendor_Unrecognized, NULL }
{ kCPUVendor_Unrecognized, nullptr }
};

struct CPUIDInfo
Expand Down Expand Up @@ -197,7 +197,7 @@ CPUIDInfo::CPUIDInfo() :
std::memcpy(vendor + 4, &info[CPUID_EDX], 4);
std::memcpy(vendor + 8, &info[CPUID_ECX], 4);
vendor[12] = '\0';
for (CPUVendorInfo* p = gCPUVendorInfo; p->cpuidString != NULL; ++p)
for (CPUVendorInfo* p = gCPUVendorInfo; p->cpuidString != nullptr; ++p)
{
if (strcmp(vendor, p->cpuidString) == 0)
{
Expand Down
12 changes: 6 additions & 6 deletions platform/x86/optimizednoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -92,8 +92,8 @@ OptimizedNoiseInfo gaOptimizedNoiseInfo[] = {
AVXFMA4DNoise, // dNoise,
&kAVXFMA4NoiseEnabled, // enabled,
AVXFMA4Supported, // supported,
NULL, // recommended,
NULL // init
nullptr, // recommended,
nullptr // init
},
#endif
#ifdef TRY_OPTIMIZED_NOISE_AVX
Expand All @@ -116,12 +116,12 @@ OptimizedNoiseInfo gaOptimizedNoiseInfo[] = {
AVXPortableDNoise, // dNoise,
&kAVXPortableNoiseEnabled, // enabled,
AVXSupported, // supported,
NULL, // recommended,
NULL // init
nullptr, // recommended,
nullptr // init
},
#endif
// End-of-list entry.
{ NULL }
{ nullptr }
};

}
Expand Down
4 changes: 2 additions & 2 deletions source/backend/configbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ static_assert(
///
/// @param[in] ts Null-terminated byte sequence to convert.
/// @param[out] as Number of UCS2 characters in result.
/// @return Converted null-terminated UCS2 character sequence, or `NULL` if conversion is not supported.
/// @return Converted null-terminated UCS2 character sequence, or `nullptr` if conversion is not supported.
///
#ifndef POV_CONVERT_TEXT_TO_UCS2
#define POV_CONVERT_TEXT_TO_UCS2(ts, as) (NULL)
#define POV_CONVERT_TEXT_TO_UCS2(ts, as) (nullptr)
#endif

//******************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions source/backend/control/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -53,15 +53,15 @@ bool Write_Benchmark_File (const char *Scene_File_Name, const char *INI_File_Nam
{
FILE *outF ;

if ((outF = fopen (Scene_File_Name, "wt")) == NULL)
if ((outF = fopen (Scene_File_Name, "wt")) == nullptr)
return (false) ;
if (fputs (Benchmark_File, outF) == EOF)
{
fclose (outF) ;
return (false) ;
}
fclose (outF) ;
if ((outF = fopen (INI_File_Name, "wt")) == NULL)
if ((outF = fopen (INI_File_Name, "wt")) == nullptr)
return (false) ;
if (fputs (Benchmark_Options, outF) == EOF)
{
Expand Down
4 changes: 2 additions & 2 deletions source/backend/control/messagefactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void MessageFactory::SendMessage(MessageClass mc, WarningLevel level, const char

(void)POVMSObject_New(&msg, kPOVObjectClass_ControlData);

if (filename != NULL)
if (filename != nullptr)
(void)POVMSUtil_SetUCS2String(&msg, kPOVAttrib_FileName, filename);
if (line != -1)
(void)POVMSUtil_SetLong(&msg, kPOVAttrib_Line, line);
Expand Down Expand Up @@ -126,7 +126,7 @@ void MessageFactory::SendMessage(MessageClass mc, WarningLevel level, const char
(void)POVMSMsg_SetSourceAddress(&msg, sourceAddress);
(void)POVMSMsg_SetDestinationAddress(&msg, destinationAddress);

(void)POVMS_Send(NULL, &msg, NULL, kPOVMSSendMode_NoReply);
(void)POVMS_Send(nullptr, &msg, nullptr, kPOVMSSendMode_NoReply);
}

}
2 changes: 1 addition & 1 deletion source/backend/control/messagefactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MessageFactory : public GenericMessenger
RenderBackend::ViewId viewId;

virtual void SendMessage(MessageClass mc, WarningLevel level, const char *text,
const UCS2 *filename = NULL, POV_LONG line = -1, POV_LONG column = -1, POV_OFF_T offset = -1);
const UCS2 *filename = nullptr, POV_LONG line = -1, POV_LONG column = -1, POV_OFF_T offset = -1);
};

}
Expand Down
34 changes: 17 additions & 17 deletions source/backend/control/renderbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace pov

using namespace pov_base;

POVMSContext RenderBackend::context = NULL;
POVMSContext RenderBackend::context = nullptr;

RenderBackend::RenderBackend(POVMSContext ctx, bool (*val)(POVMSAddress)) :
POVMS_MessageReceiver(ctx),
Expand Down Expand Up @@ -94,7 +94,7 @@ void RenderBackend::SendSceneOutput(SceneId sid, POVMSAddress addr, POVMSType id
msg.SetInt(kPOVAttrib_SceneId, sid);
msg.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, msg, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, msg, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType ident, POVMS_Object& obj)
Expand All @@ -104,7 +104,7 @@ void RenderBackend::SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType iden
msg.SetInt(kPOVAttrib_ViewId, vid);
msg.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, msg, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, msg, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const vector<POVMSUCS2String>& filenames, POVMSUCS2String& filename)
Expand Down Expand Up @@ -154,7 +154,7 @@ void RenderBackend::SendCreatedFile(POVMSContext ctx, SceneId sid, POVMSAddress
msg.SetInt(kPOVAttrib_SceneId, sid);
msg.SetDestinationAddress(addr);

POVMS_SendMessage(ctx, msg, NULL, kPOVMSSendMode_NoReply);
POVMS_SendMessage(ctx, msg, nullptr, kPOVMSSendMode_NoReply);
}

void RenderBackend::SendSuccessResult(POVMSAddress addr)
Expand All @@ -163,7 +163,7 @@ void RenderBackend::SendSuccessResult(POVMSAddress addr)

result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendFailedResult(int error, POVMSAddress addr)
Expand All @@ -174,7 +174,7 @@ void RenderBackend::SendFailedResult(int error, POVMSAddress addr)
result.SetString(kPOVAttrib_EnglishText, pov_base::Exception::lookup_code(error).c_str());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendFailedResult(const pov_base::Exception& e, POVMSAddress addr)
Expand All @@ -186,7 +186,7 @@ void RenderBackend::SendFailedResult(const pov_base::Exception& e, POVMSAddress
result.SetString(kPOVAttrib_EnglishText, e.what());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendFailedResult(const char *str, POVMSAddress addr)
Expand All @@ -196,7 +196,7 @@ void RenderBackend::SendFailedResult(const char *str, POVMSAddress addr)
result.SetString(kPOVAttrib_EnglishText, str);
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendSceneSuccessResult(SceneId sid, POVMSAddress addr)
Expand All @@ -206,7 +206,7 @@ void RenderBackend::SendSceneSuccessResult(SceneId sid, POVMSAddress addr)
result.SetInt(kPOVAttrib_SceneId, sid);
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendSceneFailedResult(SceneId sid, int error, POVMSAddress addr)
Expand All @@ -218,7 +218,7 @@ void RenderBackend::SendSceneFailedResult(SceneId sid, int error, POVMSAddress a
result.SetString(kPOVAttrib_EnglishText, pov_base::Exception::lookup_code(error).c_str());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendSceneFailedResult(SceneId sid, const pov_base::Exception& e, POVMSAddress addr)
Expand All @@ -231,7 +231,7 @@ void RenderBackend::SendSceneFailedResult(SceneId sid, const pov_base::Exception
result.SetString(kPOVAttrib_EnglishText, e.what());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendSceneFailedResult(SceneId sid, const char *str, POVMSAddress addr)
Expand All @@ -242,7 +242,7 @@ void RenderBackend::SendSceneFailedResult(SceneId sid, const char *str, POVMSAdd
result.SetString(kPOVAttrib_EnglishText, str);
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendViewSuccessResult(ViewId vid, POVMSAddress addr)
Expand All @@ -252,7 +252,7 @@ void RenderBackend::SendViewSuccessResult(ViewId vid, POVMSAddress addr)
result.SetInt(kPOVAttrib_ViewId, vid);
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendViewFailedResult(ViewId vid, int error, POVMSAddress addr)
Expand All @@ -264,7 +264,7 @@ void RenderBackend::SendViewFailedResult(ViewId vid, int error, POVMSAddress add
result.SetString(kPOVAttrib_EnglishText, pov_base::Exception::lookup_code(error).c_str());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendViewFailedResult(ViewId vid, const pov_base::Exception& e, POVMSAddress addr)
Expand All @@ -277,7 +277,7 @@ void RenderBackend::SendViewFailedResult(ViewId vid, const pov_base::Exception&
result.SetString(kPOVAttrib_EnglishText, e.what());
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::SendViewFailedResult(ViewId vid, const char *str, POVMSAddress addr)
Expand All @@ -288,7 +288,7 @@ void RenderBackend::SendViewFailedResult(ViewId vid, const char *str, POVMSAddre
result.SetString(kPOVAttrib_EnglishText, str);
result.SetDestinationAddress(addr);

POVMS_SendMessage(RenderBackend::context, result, NULL, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
POVMS_SendMessage(RenderBackend::context, result, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}

void RenderBackend::CreateScene(POVMS_Message& msg, POVMS_Message& result, int)
Expand Down
8 changes: 4 additions & 4 deletions source/backend/control/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ namespace pov
Scene::Scene(POVMSAddress backendAddr, POVMSAddress frontendAddr, RenderBackend::SceneId sid) :
sceneData(new BackendSceneData()),
stopRequsted(false),
parserControlThread(NULL)
parserControlThread(nullptr)
{
sceneData->tree = NULL;
sceneData->tree = nullptr;
sceneData->sceneId = sid;
sceneData->backendAddress = backendAddr;
sceneData->frontendAddress = frontendAddr;
Expand All @@ -71,7 +71,7 @@ Scene::~Scene()
stopRequsted = true; // NOTE: Order is important here, set this before stopping the queue!
parserTasks.Stop();

if(parserControlThread != NULL)
if (parserControlThread != nullptr)
parserControlThread->join();
delete parserControlThread;

Expand All @@ -83,7 +83,7 @@ Scene::~Scene()
void Scene::StartParser(POVMS_Object& parseOptions)
{
// A scene can only be parsed once
if(parserControlThread == NULL)
if (parserControlThread == nullptr)
parserControlThread = Task::NewBoostThread(boost::bind(&Scene::ParserControlThread, this), POV_THREAD_STACK_SIZE);
else
return;
Expand Down
4 changes: 2 additions & 2 deletions source/backend/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -118,7 +118,7 @@ class Ray;

inline void Destroy_Float(DBL *x)
{
if(x != NULL)
if (x != nullptr)
delete x;
}

Expand Down
Loading

0 comments on commit 917a876

Please sign in to comment.