103103
104104Targa::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
937937char *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
980980char *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)
13401340void 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}
13481348bool 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
0 commit comments