Skip to content

Commit dcd010a

Browse files
committed
refactor: modernize NULL to nullptr in WWLib headers and sources
1 parent 94354fd commit dcd010a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+294
-267
lines changed

Core/Libraries/Source/WWVegas/WWLib/BUFF.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#pragma once
3838

39+
#include <Utility/CppMacros.h>
3940
/*
4041
** The "bool" integral type was defined by the C++ committee in
4142
** November of '94. Until the compiler supports this, use the following
@@ -52,7 +53,7 @@
5253
class Buffer {
5354
public:
5455
Buffer(char * ptr, long size=0);
55-
Buffer(void * ptr=0, long size=0);
56+
Buffer(void * ptr=nullptr, long size=0);
5657
Buffer(void const * ptr, long size=0);
5758
Buffer(long size);
5859
Buffer(Buffer const & buffer);
@@ -65,7 +66,7 @@ class Buffer {
6566
void Reset(void);
6667
void * Get_Buffer(void) const {return(BufferPtr);}
6768
long Get_Size(void) const {return(Size);}
68-
bool Is_Valid(void) const {return(BufferPtr != 0);}
69+
bool Is_Valid(void) const {return(BufferPtr != nullptr);}
6970

7071
protected:
7172

Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "DbgHelpLoader.h"
2020

2121

22-
DbgHelpLoader* DbgHelpLoader::Inst = NULL;
22+
DbgHelpLoader* DbgHelpLoader::Inst = nullptr;
2323
CriticalSectionClass DbgHelpLoader::CriticalSection;
2424

2525
DbgHelpLoader::DbgHelpLoader()
@@ -48,7 +48,7 @@ bool DbgHelpLoader::isLoaded()
4848
{
4949
CriticalSectionClass::LockClass lock(CriticalSection);
5050

51-
return Inst != NULL && Inst->m_dllModule != HMODULE(0);
51+
return Inst != nullptr && Inst->m_dllModule != HMODULE(0);
5252
}
5353

5454
bool DbgHelpLoader::isLoadedFromSystem()
@@ -62,14 +62,14 @@ bool DbgHelpLoader::isFailed()
6262
{
6363
CriticalSectionClass::LockClass lock(CriticalSection);
6464

65-
return Inst != NULL && Inst->m_failed;
65+
return Inst != nullptr && Inst->m_failed;
6666
}
6767

6868
bool DbgHelpLoader::load()
6969
{
7070
CriticalSectionClass::LockClass lock(CriticalSection);
7171

72-
if (Inst == NULL)
72+
if (Inst == nullptr)
7373
{
7474
// Cannot use new/delete here when this is loaded during game memory initialization.
7575
void* p = GlobalAlloc(GMEM_FIXED, sizeof(DbgHelpLoader));
@@ -133,7 +133,7 @@ void DbgHelpLoader::unload()
133133
{
134134
CriticalSectionClass::LockClass lock(CriticalSection);
135135

136-
if (Inst == NULL)
136+
if (Inst == nullptr)
137137
return;
138138

139139
if (--Inst->m_referenceCount != 0)
@@ -143,7 +143,7 @@ void DbgHelpLoader::unload()
143143

144144
Inst->~DbgHelpLoader();
145145
GlobalFree(Inst);
146-
Inst = NULL;
146+
Inst = nullptr;
147147
}
148148

149149
void DbgHelpLoader::freeResources()
@@ -233,7 +233,7 @@ BOOL DbgHelpLoader::symLoadModule(
233233
{
234234
CriticalSectionClass::LockClass lock(CriticalSection);
235235

236-
if (Inst != NULL && Inst->m_symLoadModule)
236+
if (Inst != nullptr && Inst->m_symLoadModule)
237237
return Inst->m_symLoadModule(hProcess, hFile, ImageName, ModuleName, BaseOfDll, SizeOfDll);
238238

239239
return FALSE;
@@ -245,7 +245,7 @@ DWORD DbgHelpLoader::symGetModuleBase(
245245
{
246246
CriticalSectionClass::LockClass lock(CriticalSection);
247247

248-
if (Inst != NULL && Inst->m_symGetModuleBase)
248+
if (Inst != nullptr && Inst->m_symGetModuleBase)
249249
return Inst->m_symGetModuleBase(hProcess, dwAddr);
250250

251251
return 0u;
@@ -257,7 +257,7 @@ BOOL DbgHelpLoader::symUnloadModule(
257257
{
258258
CriticalSectionClass::LockClass lock(CriticalSection);
259259

260-
if (Inst != NULL && Inst->m_symUnloadModule)
260+
if (Inst != nullptr && Inst->m_symUnloadModule)
261261
return Inst->m_symUnloadModule(hProcess, BaseOfDll);
262262

263263
return FALSE;
@@ -271,7 +271,7 @@ BOOL DbgHelpLoader::symGetSymFromAddr(
271271
{
272272
CriticalSectionClass::LockClass lock(CriticalSection);
273273

274-
if (Inst != NULL && Inst->m_symGetSymFromAddr)
274+
if (Inst != nullptr && Inst->m_symGetSymFromAddr)
275275
return Inst->m_symGetSymFromAddr(hProcess, Address, Displacement, Symbol);
276276

277277
return FALSE;
@@ -285,7 +285,7 @@ BOOL DbgHelpLoader::symGetLineFromAddr(
285285
{
286286
CriticalSectionClass::LockClass lock(CriticalSection);
287287

288-
if (Inst != NULL && Inst->m_symGetLineFromAddr)
288+
if (Inst != nullptr && Inst->m_symGetLineFromAddr)
289289
return Inst->m_symGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line);
290290

291291
return FALSE;
@@ -296,7 +296,7 @@ DWORD DbgHelpLoader::symSetOptions(
296296
{
297297
CriticalSectionClass::LockClass lock(CriticalSection);
298298

299-
if (Inst != NULL && Inst->m_symSetOptions)
299+
if (Inst != nullptr && Inst->m_symSetOptions)
300300
return Inst->m_symSetOptions(SymOptions);
301301

302302
return 0u;
@@ -308,7 +308,7 @@ LPVOID DbgHelpLoader::symFunctionTableAccess(
308308
{
309309
CriticalSectionClass::LockClass lock(CriticalSection);
310310

311-
if (Inst != NULL && Inst->m_symFunctionTableAccess)
311+
if (Inst != nullptr && Inst->m_symFunctionTableAccess)
312312
return Inst->m_symFunctionTableAccess(hProcess, AddrBase);
313313

314314
return NULL;
@@ -327,7 +327,7 @@ BOOL DbgHelpLoader::stackWalk(
327327
{
328328
CriticalSectionClass::LockClass lock(CriticalSection);
329329

330-
if (Inst != NULL && Inst->m_stackWalk)
330+
if (Inst != nullptr && Inst->m_stackWalk)
331331
return Inst->m_stackWalk(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress);
332332

333333
return FALSE;

Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
///////////////////////////////////////////////////////////////////////////////
3737
// Include files
3838
//
39+
40+
#include <Utility/CppMacros.h>
3941
#include "always.h"
4042
#include "wwdebug.h"
4143
#include "mutex.h"
@@ -255,7 +257,7 @@ WWINLINE void* FastFixedAllocator::Alloc()
255257
{
256258
TotalAllocationCount++;
257259
TotalAllocatedSize+=esize;
258-
if (head==0) {
260+
if (head==nullptr) {
259261
grow();
260262
}
261263
Link* p = head;
@@ -286,8 +288,8 @@ WWINLINE void FastFixedAllocator::Free(void* pAlloc)
286288

287289
WWINLINE FastFixedAllocator::FastFixedAllocator(unsigned int n) : esize(1), TotalHeapSize(0), TotalAllocatedSize(0), TotalAllocationCount(0)
288290
{
289-
head = 0;
290-
chunks = 0;
291+
head = nullptr;
292+
chunks = nullptr;
291293
Init(n);
292294
}
293295

@@ -336,7 +338,7 @@ WWINLINE void FastFixedAllocator::grow()
336338
char* last = &start[(nelem-1)*esize];
337339
for(char* p = start; p<last; p+=esize)
338340
reinterpret_cast<Link*>(p)->next = reinterpret_cast<Link*>(p+esize);
339-
reinterpret_cast<Link*>(last)->next = 0;
341+
reinterpret_cast<Link*>(last)->next = nullptr;
340342
head = reinterpret_cast<Link*>(start);
341343
}
342344

@@ -507,7 +509,7 @@ WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){
507509
return pNewAlloc;
508510
}
509511
Free(pAlloc);
510-
return NULL;
512+
return nullptr;
511513
}
512514

513515

@@ -586,7 +588,7 @@ WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){
586588
pointer address(reference x) const { return &x; }
587589
const_pointer address(const_reference x) const { return &x; }
588590

589-
T* allocate(size_type n, const void* = NULL) { return n != 0 ? static_cast<T*>(FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T))) : NULL; }
591+
T* allocate(size_type n, const void* = nullptr) { return n != 0 ? static_cast<T*>(FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T))) : NULL; }
590592
void deallocate(pointer p, size_type n) { FastAllocatorGeneral::Get_Allocator()->Free(p); }
591593
size_type max_size() const { return size_t(-1) / sizeof(T); }
592594
void construct(pointer p, const T& val) { new(p) T(val); }

Core/Libraries/Source/WWVegas/WWLib/INI.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
#include <wchar.h>
4040

41+
#include <Utility/CppMacros.h>
42+
4143
//#include "listnode.h"
4244
//#include "trect.h"
4345
//#include "index.h"
@@ -107,19 +109,19 @@ class INIClass {
107109
/*
108110
** Erase all data within this INI file manager.
109111
*/
110-
bool Clear(char const * section = NULL, char const * entry = NULL);
112+
bool Clear(char const * section = nullptr, char const * entry = nullptr);
111113

112114
// int Line_Count(char const * section) const;
113115
bool Is_Loaded(void) const;
114116
int Size(void) const;
115-
bool Is_Present(char const * section, char const * entry = NULL) const {if (entry == 0) return(Find_Section(section) != 0);return(Find_Entry(section, entry) != 0);}
117+
bool Is_Present(char const * section, char const * entry = nullptr) const {if (entry == nullptr) return(Find_Section(section) != nullptr);return(Find_Entry(section, entry) != nullptr);}
116118

117119
/*
118120
** Fetch the number of sections in the INI file or verify if a specific
119121
** section is present.
120122
*/
121123
int Section_Count(void) const;
122-
bool Section_Present(char const * section) const {return(Find_Section(section) != NULL);}
124+
bool Section_Present(char const * section) const {return(Find_Section(section) != nullptr);}
123125

124126
/*
125127
** Fetch the number of entries in a section or get a particular entry in a section.

Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#pragma once
3838

39+
#include <Utility/CppMacros.h>
3940
/*
4041
** Includes
4142
*/
@@ -55,7 +56,7 @@
5556
class GenericList;
5657
class GenericNode {
5758
public:
58-
GenericNode(void) : NextNode(0), PrevNode(0) {}
59+
GenericNode(void) : NextNode(nullptr), PrevNode(nullptr) {}
5960
virtual ~GenericNode(void) {Unlink();}
6061
GenericNode(GenericNode & node) {node.Link(this);}
6162
GenericNode & operator = (GenericNode & node) {
@@ -73,8 +74,8 @@ class GenericNode {
7374
if (Is_Valid()) {
7475
PrevNode->NextNode = NextNode;
7576
NextNode->PrevNode = PrevNode;
76-
PrevNode = 0;
77-
NextNode = 0;
77+
PrevNode = nullptr;
78+
NextNode = nullptr;
7879
}
7980
}
8081

@@ -96,13 +97,13 @@ class GenericNode {
9697

9798
GenericNode * Next(void) const {return(NextNode);}
9899
GenericNode * Next_Valid(void) const {
99-
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)0);
100+
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)nullptr);
100101
}
101102
GenericNode * Prev(void) const {return(PrevNode);}
102103
GenericNode * Prev_Valid(void) const {
103-
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)0);
104+
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)nullptr);
104105
}
105-
bool Is_Valid(void) const {return(this != (GenericNode *)0 && NextNode != (GenericNode *)0 && PrevNode != (GenericNode *)0);}
106+
bool Is_Valid(void) const {return(this != (GenericNode *)nullptr && NextNode != (GenericNode *)nullptr && PrevNode != (GenericNode *)nullptr);}
106107

107108
protected:
108109
GenericNode * NextNode;
@@ -131,14 +132,14 @@ class GenericList {
131132
GenericNode * First_Valid(void) const
132133
{
133134
GenericNode *node = FirstNode.Next();
134-
return (node->Next() ? node : (GenericNode *)0);
135+
return (node->Next() ? node : (GenericNode *)nullptr);
135136
}
136137

137138
GenericNode * Last(void) const {return(LastNode.Prev());}
138139
GenericNode * Last_Valid(void) const
139140
{
140141
GenericNode *node = LastNode.Prev();
141-
return (node->Prev() ? node : (GenericNode *)0);
142+
return (node->Prev() ? node : (GenericNode *)nullptr);
142143
}
143144

144145
bool Is_Empty(void) const {return(!FirstNode.Next()->Is_Valid());}

Core/Libraries/Source/WWVegas/WWLib/PIPE.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#pragma once
3838

39+
#include <Utility/CppMacros.h>
3940
/*
4041
** A "push through" pipe interface abstract class used for such purposes as compression
4142
** and translation of data. In STL terms, this is functionally similar to an output
@@ -46,7 +47,7 @@
4647
class Pipe
4748
{
4849
public:
49-
Pipe(void) : ChainTo(0), ChainFrom(0) {}
50+
Pipe(void) : ChainTo(nullptr), ChainFrom(nullptr) {}
5051
virtual ~Pipe(void);
5152

5253
virtual int Flush(void);

Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#pragma once
3838

39+
#include <Utility/CppMacros.h>
3940
#include "WWFILE.h"
4041

4142

@@ -60,7 +61,7 @@ class RAMFileClass : public FileClass
6061
virtual void Close(void);
6162
virtual unsigned long Get_Date_Time(void) {return(0);}
6263
virtual bool Set_Date_Time(unsigned long ) {return(true);}
63-
virtual void Error(int , int = false, char const * =NULL) {}
64+
virtual void Error(int , int = false, char const * =nullptr) {}
6465
virtual void Bias(int start, int length=-1);
6566

6667
operator char const * () {return File_Name();}

Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
#define NULL_HANDLE NULL
4848
#define HANDLE_TYPE FILE*
49+
50+
#include <Utility/CppMacros.h>
4951
#include "WWFILE.h"
5052
#include "wwstring.h"
5153

@@ -98,7 +100,7 @@ class RawFileClass : public FileClass
98100
virtual void Close(void);
99101
virtual unsigned long Get_Date_Time(void);
100102
virtual bool Set_Date_Time(unsigned long datetime);
101-
virtual void Error(int error, int canretry = false, char const * filename=NULL);
103+
virtual void Error(int error, int canretry = false, char const * filename=nullptr);
102104
virtual void Bias(int start, int length=-1);
103105
virtual void * Get_File_Handle(void) { return Handle; }
104106

Core/Libraries/Source/WWVegas/WWLib/SLNODE.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#pragma once
3636

37+
#include <Utility/CppMacros.h>
3738
#include "always.h"
3839
#include "mempool.h"
3940

@@ -64,7 +65,7 @@ class GenericSLNode : public AutoPoolClass<GenericSLNode, 256>
6465
// created from anything but a friend or parent class.
6566
//
6667
GenericSLNode(void *obj)
67-
{NodeData = obj; NodeNext = 0; };
68+
{NodeData = obj; NodeNext = nullptr; };
6869

6970
//
7071
// You cannot declare a node class without giving it a data object.

Core/Libraries/Source/WWVegas/WWLib/STRAW.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#pragma once
3838

39+
#include <Utility/CppMacros.h>
3940
/*
4041
** This is a demand driven data carrier. It will retrieve the byte request by passing
4142
** the request down the chain (possibly processing on the way) in order to fulfill the
@@ -46,7 +47,7 @@
4647
class Straw
4748
{
4849
public:
49-
Straw(void) : ChainTo(0), ChainFrom(0) {}
50+
Straw(void) : ChainTo(nullptr), ChainFrom(nullptr) {}
5051
virtual ~Straw(void);
5152

5253
virtual void Get_From(Straw * pipe);

0 commit comments

Comments
 (0)