102102
103103Targa::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
936936char *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
979979char *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)
13391339void 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}
13471347bool 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
0 commit comments