X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=6276a5bcd1f5dad974f59d271a14636f6d06621a;hb=refs%2Ftags%2FVersion0.6.bp;hp=a528e28c3bfac903213acbd32c7c7726d5a12e3d;hpb=80f7a0ffbc39a8a7c47c2a8c6c9a272515d55d6f;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index a528e28c..6276a5bc 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/10/22 13:56:46 $ - Version: $Revision: 1.149 $ + Date: $Date: 2004/11/05 21:23:46 $ + Version: $Revision: 1.152 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -73,6 +73,7 @@ File::File(std::string const & filename ) */ void File::Initialise() { + PixelConverter = NULL; //just in case if ( HeaderInternal->IsReadable() ) { ImageDataSizeRaw = ComputeDecompressedPixelDataSizeFromHeader(); @@ -85,7 +86,7 @@ void File::Initialise() ImageDataSize = ImageDataSizeRaw; } - PixelConverter = new PixelConvert; + PixelConverter = new PixelConvert; //LEAK ! PixelConverter->GrabInformationsFromHeader( HeaderInternal ); } SaveInitialValues(); @@ -105,6 +106,11 @@ File::~File() HeaderInternal = 0; DeleteInitialValues(); + if( PixelConverter ) + { + //delete PixelConverter; + } + } /** @@ -274,7 +280,7 @@ int File::ComputeDecompressedPixelDataSizeFromHeader() // - it is not defined (i.e. it's value is 0) // - it's 12, since we will expand the image to 16 bits (see // PixelConvert::ConvertDecompress12BitsTo16Bits() ) - if ( ( numberBitsAllocated == 0 ) || ( numberBitsAllocated == 12 ) ) + if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 ) { numberBitsAllocated = 16; } @@ -558,7 +564,7 @@ bool File::WriteRawData(std::string const & fileName) std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary ); if (!fp1) { - printf("Fail to open (write) file [%s] \n", fileName.c_str()); + dbg.Verbose(2, "Fail to open (write) file:", fileName.c_str()); return false; } fp1.write((char*)Pixel_Data, ImageDataSize); @@ -634,19 +640,17 @@ bool File::WriteBase (std::string const & fileName, FileType type) std::ios::out | std::ios::binary); if (fp1 == NULL) { - printf("Failed to open (write) File [%s] \n", fileName.c_str()); + dbg.Verbose(2, "Failed to open (write) File: " , fileName.c_str()); return false; } if ( type == ImplicitVR || type == ExplicitVR ) { // writing Dicom File Preamble - uint8_t* filePreamble = new uint8_t[128]; + char filePreamble[128]; memset(filePreamble, 0, 128); - fp1->write((char*)filePreamble, 128); + fp1->write(filePreamble, 128); fp1->write("DICM", 4); - - delete[] filePreamble; } // -------------------------------------------------------------- @@ -702,6 +706,7 @@ bool File::WriteBase (std::string const & fileName, FileType type) } // ----------------- End of Special Patch ---------------- fp1->close (); + delete fp1; return true; }