Skip to content

Commit 1e459b2

Browse files
committed
refactor(core): modernize NULL to nullptr
1 parent 1df3c49 commit 1e459b2

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
@@ -56,7 +56,7 @@
5656
class GenericList;
5757
class GenericNode {
5858
public:
59-
GenericNode(void) : NextNode(0), PrevNode(0) {}
59+
GenericNode(void) : NextNode(nullptr), PrevNode(nullptr) {}
6060
virtual ~GenericNode(void) {Unlink();}
6161
GenericNode(GenericNode & node) {node.Link(this);}
6262
GenericNode & operator = (GenericNode & node) {
@@ -74,8 +74,8 @@ class GenericNode {
7474
if (Is_Valid()) {
7575
PrevNode->NextNode = NextNode;
7676
NextNode->PrevNode = PrevNode;
77-
PrevNode = 0;
78-
NextNode = 0;
77+
PrevNode = nullptr;
78+
NextNode = nullptr;
7979
}
8080
}
8181

@@ -97,13 +97,13 @@ class GenericNode {
9797

9898
GenericNode * Next(void) const {return(NextNode);}
9999
GenericNode * Next_Valid(void) const {
100-
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)0);
100+
return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)nullptr);
101101
}
102102
GenericNode * Prev(void) const {return(PrevNode);}
103103
GenericNode * Prev_Valid(void) const {
104-
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)0);
104+
return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)nullptr);
105105
}
106-
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);}
107107

108108
protected:
109109
GenericNode * NextNode;
@@ -132,14 +132,14 @@ class GenericList {
132132
GenericNode * First_Valid(void) const
133133
{
134134
GenericNode *node = FirstNode.Next();
135-
return (node->Next() ? node : (GenericNode *)0);
135+
return (node->Next() ? node : (GenericNode *)nullptr);
136136
}
137137

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

145145
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
@@ -103,8 +103,8 @@
103103

104104
Targa::Targa(void)
105105
{
106-
mImage = NULL;
107-
mPalette = NULL;
106+
mImage = nullptr;
107+
mPalette = nullptr;
108108
Clear_File();
109109
mAccess = TGA_READMODE;
110110
mFlags = 0;
@@ -139,11 +139,11 @@ Targa::~Targa(void)
139139
Close();
140140

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

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

@@ -318,7 +318,7 @@ void Targa::Close(void)
318318
if (TGAFile) {
319319
TGAFile->Close();
320320
_TheFileFactory->Return_File(TGAFile);
321-
TGAFile = NULL;
321+
TGAFile = nullptr;
322322
}
323323
#else
324324
/* Close the file if it is open. */
@@ -372,7 +372,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image)
372372
/* Load the palette from the TGA if a palette buffer is provided
373373
* otherwise we will skip it.
374374
*/
375-
if ((palette != NULL) && (Header.CMapLength > 0)) {
375+
if ((palette != nullptr) && (Header.CMapLength > 0)) {
376376

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

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

502502
/* Dispose of any previous palette. */
503-
if ((mPalette != NULL) && (mFlags & TGAF_PAL)) {
503+
if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) {
504504
free(mPalette);
505-
mPalette = NULL;
505+
mPalette = nullptr;
506506
mFlags &= ~TGAF_PAL;
507507
}
508508

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

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

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

529529
/* Dispose of any previous image. */
530-
if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) {
530+
if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) {
531531
free(mImage);
532-
mImage = NULL;
532+
mImage = nullptr;
533533
mFlags &= ~TGAF_IMAGE;
534534
}
535535

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

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

646646
/* Allocate temporary buffer for palette manipulation. */
647-
if ((temppal = (char *)malloc(size)) != NULL)
647+
if ((temppal = (char *)malloc(size)) != nullptr)
648648
{
649649
memcpy(temppal, palette, size);
650650
ptr = temppal;
@@ -676,7 +676,7 @@ long Targa::Save(const char* name, long flags, bool addextension)
676676
/*-----------------------------------------------------------------------
677677
* WRITE THE IMAGE DATA SECTION
678678
*---------------------------------------------------------------------*/
679-
if (!error && (flags & TGAF_IMAGE) && (mImage != NULL))
679+
if (!error && (flags & TGAF_IMAGE) && (mImage != nullptr))
680680
{
681681

682682
bool imageinverted;
@@ -936,18 +936,18 @@ void Targa::YFlip(void)
936936

937937
char *Targa::SetImage(char *buffer)
938938
{
939-
char *oldbuffer = NULL;
939+
char *oldbuffer = nullptr;
940940

941941
/* Free any image buffer before assigning another. */
942-
if ((mImage != NULL) && (mFlags & TGAF_IMAGE))
942+
if ((mImage != nullptr) && (mFlags & TGAF_IMAGE))
943943
{
944944
free(mImage);
945-
mImage = NULL;
945+
mImage = nullptr;
946946
mFlags &= ~TGAF_IMAGE;
947947
}
948948

949949
/* Get the old user buffer. */
950-
if (mImage != NULL)
950+
if (mImage != nullptr)
951951
oldbuffer = mImage;
952952

953953
/* Assign the new image buffer. */
@@ -979,18 +979,18 @@ char *Targa::SetImage(char *buffer)
979979

980980
char *Targa::SetPalette(char *buffer)
981981
{
982-
char *oldbuffer = NULL;
982+
char *oldbuffer = nullptr;
983983

984984
/* Free any image buffer before assigning another. */
985-
if ((mPalette != NULL) && (mFlags & TGAF_PAL))
985+
if ((mPalette != nullptr) && (mFlags & TGAF_PAL))
986986
{
987987
free(mPalette);
988-
mPalette = NULL;
988+
mPalette = nullptr;
989989
mFlags &= ~TGAF_PAL;
990990
}
991991

992992
/* Get the old user buffer. */
993-
if (mPalette != NULL)
993+
if (mPalette != nullptr)
994994
oldbuffer = mPalette;
995995

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

1039-
return (NULL);
1039+
return (nullptr);
10401040
}
10411041

10421042

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

11731173
/* Allocate packet buffer to hold maximum encoded data run. */
1174-
if ((packet = (char *)malloc(128 * depth)) != NULL)
1174+
if ((packet = (char *)malloc(128 * depth)) != nullptr)
11751175
{
11761176
pixels = Header.Width * Header.Height;
11771177
start = mImage;
@@ -1340,15 +1340,15 @@ void Targa::InvertImage(void)
13401340
void Targa::Clear_File(void)
13411341
{
13421342
#ifdef TGA_USES_WWLIB_FILE_CLASSES
1343-
TGAFile = NULL;
1343+
TGAFile = nullptr;
13441344
#else
13451345
mFH = -1;
13461346
#endif
13471347
}
13481348
bool Targa::Is_File_Open(void)
13491349
{
13501350
#ifdef TGA_USES_WWLIB_FILE_CLASSES
1351-
return (TGAFile != NULL);
1351+
return (TGAFile != nullptr);
13521352
#else
13531353
return (mFH != -1);
13541354
#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)