Skip to content

Commit 4fae41b

Browse files
committed
refactor(core): modernize NULL to nullptr
1 parent ae7d1b5 commit 4fae41b

40 files changed

+308
-308
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
class GenericList;
5656
class GenericNode {
5757
public:
58-
GenericNode(void) : NextNode(0), PrevNode(0) {}
58+
GenericNode(void) : NextNode(nullptr), PrevNode(nullptr) {}
5959
virtual ~GenericNode(void) {Unlink();}
6060
GenericNode(GenericNode & node) {node.Link(this);}
6161
GenericNode & operator = (GenericNode & node) {
@@ -73,8 +73,8 @@ class GenericNode {
7373
if (Is_Valid()) {
7474
PrevNode->NextNode = NextNode;
7575
NextNode->PrevNode = PrevNode;
76-
PrevNode = 0;
77-
NextNode = 0;
76+
PrevNode = nullptr;
77+
NextNode = nullptr;
7878
}
7979
}
8080

@@ -96,13 +96,13 @@ class GenericNode {
9696

9797
GenericNode * Next(void) const {return(NextNode);}
9898
GenericNode * Next_Valid(void) const {
99-
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)0);
99+
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)nullptr);
100100
}
101101
GenericNode * Prev(void) const {return(PrevNode);}
102102
GenericNode * Prev_Valid(void) const {
103-
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)0);
103+
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)nullptr);
104104
}
105-
bool Is_Valid(void) const {return(this != (GenericNode *)0 && NextNode != (GenericNode *)0 && PrevNode != (GenericNode *)0);}
105+
bool Is_Valid(void) const {return(this != (GenericNode *)nullptr && NextNode != (GenericNode *)nullptr && PrevNode != (GenericNode *)nullptr);}
106106

107107
protected:
108108
GenericNode * NextNode;
@@ -131,14 +131,14 @@ class GenericList {
131131
GenericNode * First_Valid(void) const
132132
{
133133
GenericNode *node = FirstNode.Next();
134-
return (node->Next() ? node : (GenericNode *)0);
134+
return (node->Next() ? node : (GenericNode *)nullptr);
135135
}
136136

137137
GenericNode * Last(void) const {return(LastNode.Prev());}
138138
GenericNode * Last_Valid(void) const
139139
{
140140
GenericNode *node = LastNode.Prev();
141-
return (node->Prev() ? node : (GenericNode *)0);
141+
return (node->Prev() ? node : (GenericNode *)nullptr);
142142
}
143143

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class GenericSLNode : public AutoPoolClass<GenericSLNode, 256>
6464
// created from anything but a friend or parent class.
6565
//
6666
GenericSLNode(void *obj)
67-
{NodeData = obj; NodeNext = 0; };
67+
{NodeData = obj; NodeNext = nullptr; };
6868

6969
//
7070
// You cannot declare a node class without giving it a data object.

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@
102102

103103
Targa::Targa(void)
104104
{
105-
mImage = NULL;
106-
mPalette = NULL;
105+
mImage = nullptr;
106+
mPalette = nullptr;
107107
Clear_File();
108108
mAccess = TGA_READMODE;
109109
mFlags = 0;
@@ -138,11 +138,11 @@ Targa::~Targa(void)
138138
Close();
139139

140140
/* Free the palette buffer if we allocated it. */
141-
if ((mPalette != NULL) && (mFlags & TGAF_PAL))
141+
if ((mPalette != nullptr) && (mFlags & TGAF_PAL))
142142
free(mPalette);
143143

144144
/* Free the image buffer if we allocated it. */
145-
if ((mImage != NULL) && (mFlags & TGAF_IMAGE))
145+
if ((mImage != nullptr) && (mFlags & TGAF_IMAGE))
146146
free(mImage);
147147
}
148148

@@ -317,7 +317,7 @@ void Targa::Close(void)
317317
if (TGAFile) {
318318
TGAFile->Close();
319319
_TheFileFactory->Return_File(TGAFile);
320-
TGAFile = NULL;
320+
TGAFile = nullptr;
321321
}
322322
#else
323323
/* Close the file if it is open. */
@@ -371,7 +371,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image)
371371
/* Load the palette from the TGA if a palette buffer is provided
372372
* otherwise we will skip it.
373373
*/
374-
if ((palette != NULL) && (Header.CMapLength > 0)) {
374+
if ((palette != nullptr) && (Header.CMapLength > 0)) {
375375

376376
/* Adjust palette to the starting color entry. */
377377
palette += (Header.CMapStart * depth);
@@ -391,7 +391,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image)
391391
/* Load the image data from the TGA if an image buffer is provided
392392
* otherwise we are done.
393393
*/
394-
if (!error && (image != NULL)) {
394+
if (!error && (image != nullptr)) {
395395

396396
depth = TGA_BytesPerPixel(Header.PixelDepth);
397397
size = ((Header.Width * Header.Height) * depth);
@@ -499,21 +499,21 @@ long Targa::Load(const char* name, long flags, bool invert_image)
499499
if ((flags & TGAF_PAL) && (Header.ColorMapType == 1)) {
500500

501501
/* Dispose of any previous palette. */
502-
if ((mPalette != NULL) && (mFlags & TGAF_PAL)) {
502+
if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) {
503503
free(mPalette);
504-
mPalette = NULL;
504+
mPalette = nullptr;
505505
mFlags &= ~TGAF_PAL;
506506
}
507507

508508
/* Only allocate a palette if the client hasn't assigned one. */
509-
if ((mPalette == NULL) && !(mFlags & TGAF_PAL)) {
509+
if ((mPalette == nullptr) && !(mFlags & TGAF_PAL)) {
510510

511511
/* Compute the size of the palette from the targa header. */
512512
size = (Header.CMapLength * (Header.CMapDepth >> 3));
513513

514514
if (size != 0) {
515515
/* Allocate memory for the palette. */
516-
if ((mPalette = (char *)malloc(size)) != NULL) {
516+
if ((mPalette = (char *)malloc(size)) != nullptr) {
517517
mFlags |= TGAF_PAL; /* We allocated the palette. */
518518
} else {
519519
error = TGAERR_NOMEM;
@@ -526,20 +526,20 @@ long Targa::Load(const char* name, long flags, bool invert_image)
526526
if (!error && (flags & TGAF_IMAGE)) {
527527

528528
/* Dispose of any previous image. */
529-
if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) {
529+
if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) {
530530
free(mImage);
531-
mImage = NULL;
531+
mImage = nullptr;
532532
mFlags &= ~TGAF_IMAGE;
533533
}
534534

535535
/* Only allocate an image if the client hasn't assigned one. */
536-
if ((mImage == NULL) && !(mFlags & TGAF_IMAGE)) {
536+
if ((mImage == nullptr) && !(mFlags & TGAF_IMAGE)) {
537537

538538
/* Compute the size of the image data from the targa header. */
539539
size = ((Header.Width * Header.Height) * TGA_BytesPerPixel(Header.PixelDepth));
540540
if (size != 0) {
541541
/* Allocate memory for the image. */
542-
if ((mImage = (char *)malloc(size)) != NULL) {
542+
if ((mImage = (char *)malloc(size)) != nullptr) {
543543
mFlags |= TGAF_IMAGE; /* We allocated the image. */
544544
} else {
545545
error = TGAERR_NOMEM;
@@ -634,7 +634,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
634634
/*-----------------------------------------------------------------------
635635
* WRITE THE COLORMAP (PALETTE) DATA SECTION
636636
*---------------------------------------------------------------------*/
637-
if (!error && (flags & TGAF_PAL) && (mPalette != NULL)
637+
if (!error && (flags & TGAF_PAL) && (mPalette != nullptr)
638638
&& (Header.CMapLength > 0))
639639
{
640640
/* Adjust palette to the starting color entry. */
@@ -643,7 +643,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
643643
size = (Header.CMapLength * depth);
644644

645645
/* Allocate temporary buffer for palette manipulation. */
646-
if ((temppal = (char *)malloc(size)) != NULL)
646+
if ((temppal = (char *)malloc(size)) != nullptr)
647647
{
648648
memcpy(temppal, palette, size);
649649
ptr = temppal;
@@ -675,7 +675,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
675675
/*-----------------------------------------------------------------------
676676
* WRITE THE IMAGE DATA SECTION
677677
*---------------------------------------------------------------------*/
678-
if (!error && (flags & TGAF_IMAGE) && (mImage != NULL))
678+
if (!error && (flags & TGAF_IMAGE) && (mImage != nullptr))
679679
{
680680

681681
bool imageinverted;
@@ -935,18 +935,18 @@ void Targa::YFlip(void)
935935

936936
char *Targa::SetImage(char *buffer)
937937
{
938-
char *oldbuffer = NULL;
938+
char *oldbuffer = nullptr;
939939

940940
/* Free any image buffer before assigning another. */
941-
if ((mImage != NULL) && (mFlags & TGAF_IMAGE))
941+
if ((mImage != nullptr) && (mFlags & TGAF_IMAGE))
942942
{
943943
free(mImage);
944-
mImage = NULL;
944+
mImage = nullptr;
945945
mFlags &= ~TGAF_IMAGE;
946946
}
947947

948948
/* Get the old user buffer. */
949-
if (mImage != NULL)
949+
if (mImage != nullptr)
950950
oldbuffer = mImage;
951951

952952
/* Assign the new image buffer. */
@@ -978,18 +978,18 @@ char *Targa::SetImage(char *buffer)
978978

979979
char *Targa::SetPalette(char *buffer)
980980
{
981-
char *oldbuffer = NULL;
981+
char *oldbuffer = nullptr;
982982

983983
/* Free any image buffer before assigning another. */
984-
if ((mPalette != NULL) && (mFlags & TGAF_PAL))
984+
if ((mPalette != nullptr) && (mFlags & TGAF_PAL))
985985
{
986986
free(mPalette);
987-
mPalette = NULL;
987+
mPalette = nullptr;
988988
mFlags &= ~TGAF_PAL;
989989
}
990990

991991
/* Get the old user buffer. */
992-
if (mPalette != NULL)
992+
if (mPalette != nullptr)
993993
oldbuffer = mPalette;
994994

995995
/* Assign the new image buffer. */
@@ -1035,7 +1035,7 @@ TGA2Extension *Targa::GetExtension(void)
10351035
if (mFlags & TGAF_TGA2)
10361036
return (&mExtension);
10371037

1038-
return (NULL);
1038+
return (nullptr);
10391039
}
10401040

10411041

@@ -1170,7 +1170,7 @@ long Targa::EncodeImage()
11701170
depth = TGA_BytesPerPixel(Header.PixelDepth);
11711171

11721172
/* Allocate packet buffer to hold maximum encoded data run. */
1173-
if ((packet = (char *)malloc(128 * depth)) != NULL)
1173+
if ((packet = (char *)malloc(128 * depth)) != nullptr)
11741174
{
11751175
pixels = Header.Width * Header.Height;
11761176
start = mImage;
@@ -1339,15 +1339,15 @@ void Targa::InvertImage(void)
13391339
void Targa::Clear_File(void)
13401340
{
13411341
#ifdef TGA_USES_WWLIB_FILE_CLASSES
1342-
TGAFile = NULL;
1342+
TGAFile = nullptr;
13431343
#else
13441344
mFH = -1;
13451345
#endif
13461346
}
13471347
bool Targa::Is_File_Open(void)
13481348
{
13491349
#ifdef TGA_USES_WWLIB_FILE_CLASSES
1350-
return (TGAFile != NULL);
1350+
return (TGAFile != nullptr);
13511351
#else
13521352
return (mFH != -1);
13531353
#endif

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class VectorClass
153153
*=============================================================================================*/
154154
template<class T>
155155
VectorClass<T>::VectorClass(int size, T const * array) :
156-
Vector(0),
156+
Vector(nullptr),
157157
VectorMax(size),
158158
IsValid(true),
159159
IsAllocated(false)
@@ -367,7 +367,7 @@ void VectorClass<T>::Clear(void)
367367
{
368368
if (IsAllocated) {
369369
delete[] Vector;
370-
Vector = 0;
370+
Vector = nullptr;
371371
}
372372
IsAllocated = false;
373373
VectorMax = 0;
@@ -426,7 +426,7 @@ bool VectorClass<T>::Resize(int newsize, T const * array)
426426
** If there is an old vector, then it must be copied (as much as is feasible)
427427
** to the new vector.
428428
*/
429-
if (Vector != NULL) {
429+
if (Vector != nullptr) {
430430

431431
/*
432432
** Copy as much of the old vector into the new vector as possible. This
@@ -446,7 +446,7 @@ bool VectorClass<T>::Resize(int newsize, T const * array)
446446
*/
447447
if (IsAllocated) {
448448
delete[] Vector;
449-
Vector = 0;
449+
Vector = nullptr;
450450
}
451451
}
452452

@@ -489,14 +489,14 @@ class DynamicVectorClass : public VectorClass<T>
489489
using VectorClass<T>::Length;
490490

491491
public:
492-
DynamicVectorClass(unsigned size=0, T const * array=0);
492+
DynamicVectorClass(unsigned size=0, T const * array=nullptr);
493493

494494
// Stubbed equality operators so you can have dynamic vectors of dynamic vectors
495495
bool operator== (const DynamicVectorClass &src) { return false; }
496496
bool operator!= (const DynamicVectorClass &src) { return true; }
497497

498498
// Change maximum size of vector.
499-
virtual bool Resize(int newsize, T const * array=0);
499+
virtual bool Resize(int newsize, T const * array=nullptr);
500500

501501
// Resets and frees the vector array.
502502
virtual void Clear(void) {ActiveCount = 0;VectorClass<T>::Clear();};
@@ -969,7 +969,7 @@ int First_False_Bit(void const * array);
969969
class BooleanVectorClass
970970
{
971971
public:
972-
BooleanVectorClass(unsigned size=0, unsigned char * array=0);
972+
BooleanVectorClass(unsigned size=0, unsigned char * array=nullptr);
973973
BooleanVectorClass(BooleanVectorClass const & vector);
974974

975975
// Assignment operator.

0 commit comments

Comments
 (0)