From: jpr Date: Thu, 23 Sep 2004 09:40:28 +0000 (+0000) Subject: 2004-09-23 Jean-Pierre Roux X-Git-Tag: Version0.6.bp~179 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=692f863c018c259a380e664d3608a46ec0c8bb3e;p=gdcm.git 2004-09-23 Jean-Pierre Roux * FIX In order not to be poluted any longer by casting problems, the member VoidArea of gdcmBinEntry is now uint8_t* (instead of void *) we can now delete[] it safely --- diff --git a/ChangeLog b/ChangeLog index b825eda1..e09e4ba1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-09-23 Jean-Pierre Roux + * FIX In order not to be poluted any longer by casting problems, + the member VoidArea of gdcmBinEntry is now uint8_t* (instead of void *) + we can now delete[] it safely + 2004-09-22 Eric Boix * src/gdcmDocument.cxx: gdcmDocument::~gdcmDocument() doesn't clear (nor clear) TagHT, which is an inherited member of gdcmElementSet. It is diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index bfc92b8a..092e6f16 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); + uint8_t* imageData = original->GetImageData(); //First of all copy the header field by field diff --git a/Example/TestReadWriteReadCompare.cxx b/Example/TestReadWriteReadCompare.cxx index da97003a..3732918a 100644 --- a/Example/TestReadWriteReadCompare.cxx +++ b/Example/TestReadWriteReadCompare.cxx @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) gdcmFile* file = new gdcmFile( header ); int dataSize = file->GetImageDataSize(); - void* imageData = file->GetImageData(); //EXTREMELY IMPORTANT + uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to // GetImageData or if he wants to GetImageDataRaw // (even if we do it by setting a flag, he will have to decide) diff --git a/Example/TestWriteSimple.cxx b/Example/TestWriteSimple.cxx index df717bf4..37965869 100644 --- a/Example/TestWriteSimple.cxx +++ b/Example/TestWriteSimple.cxx @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) int dataSize = f2->GetImageDataSize(); // unsigned char cast is necessary to be able to delete the buffer // since deleting a void* is not allowed in c++ - char *imageData = (char*)f2->GetImageData(); + uint8_t* imageData = (uint8_t*)f2->GetImageData(); f2->SetImageData( imageData, dataSize); diff --git a/Example/WriteDicom.cxx b/Example/WriteDicom.cxx index 10554b39..18d798fd 100644 --- a/Example/WriteDicom.cxx +++ b/Example/WriteDicom.cxx @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) // and that does the job int dataSize = f2->GetImageDataSize(); - void *imageData = f2->GetImageData(); + uint8_t* imageData = f2->GetImageData(); std::cout << "dataSize :" << dataSize << std::endl; diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 2a2416ec..8bbedf69 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -70,7 +70,7 @@ int TestCopyDicom(int , char* []) TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); + uint8_t* imageData = original->GetImageData(); //First of all copy the header field by field diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index ac868dcd..d3eb11b5 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -53,7 +53,7 @@ int TestReadWriteReadCompare(int argc, char* argv[]) gdcmFile* file = new gdcmFile( header ); int dataSize = file->GetImageDataSize(); - void* imageData = file->GetImageData(); //EXTREMELY IMPORTANT + uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to // GetImageData or if he wants to GetImageDataRaw // (even if we do it by setting a flag, he will have to decide) diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index 092c1ee1..47af8c38 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.cxx,v $ Language: C++ - Date: $Date: 2004/09/20 18:14:23 $ - Version: $Revision: 1.28 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -55,7 +55,7 @@ gdcmBinEntry::~gdcmBinEntry() { if (VoidArea) { - free (VoidArea); + delete[] VoidArea; VoidArea = 0; // let's be carefull ! } } @@ -120,10 +120,10 @@ void gdcmBinEntry::Write(FILE *fp, FileType filetype) /// \brief Sets the value (non string) of the current Dicom Header Entry -void gdcmBinEntry::SetVoidArea( void* area ) +void gdcmBinEntry::SetVoidArea( uint8_t* area ) { if (VoidArea) - free(VoidArea); + delete[] VoidArea; VoidArea = area; } diff --git a/src/gdcmBinEntry.h b/src/gdcmBinEntry.h index bbc8451d..c013ee14 100644 --- a/src/gdcmBinEntry.h +++ b/src/gdcmBinEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.h,v $ Language: C++ - Date: $Date: 2004/09/13 12:10:53 $ - Version: $Revision: 1.17 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -45,8 +45,8 @@ public: /// \brief Returns the area value of the current Dicom Header Entry /// when it's not string-translatable (e.g : a LUT table) - void* GetVoidArea() { return VoidArea; } - void SetVoidArea( void* area ); + uint8_t* GetVoidArea() { return VoidArea; } + void SetVoidArea( uint8_t* area ); protected: @@ -56,7 +56,7 @@ private: /// \brief unsecure memory area to hold 'non string' values /// (ie : Lookup Tables, overlays, icons) - void *VoidArea; + uint8_t*VoidArea; }; diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 5ee4e61a..5e529a5a 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/09/22 21:39:42 $ - Version: $Revision: 1.88 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.89 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -673,7 +673,7 @@ gdcmValEntry * gdcmDocument::ReplaceOrCreateByNumber( * failed). */ gdcmBinEntry * gdcmDocument::ReplaceOrCreateByNumber( - void *voidArea, + uint8_t* voidArea, int lgth, uint16_t group, uint16_t elem, @@ -983,12 +983,12 @@ bool gdcmDocument::SetEntryByNumber(std::string const & content, * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element) * through it's (group, element) and modifies it's content with * the given value. - * @param content new value (void *) to substitute with + * @param content new value (void * -> uint8_t*) to substitute with * @param lgth new value length * @param group group number of the Dicom Element to modify * @param element element number of the Dicom Element to modify */ -bool gdcmDocument::SetEntryByNumber(void *content, +bool gdcmDocument::SetEntryByNumber(uint8_t*content, int lgth, uint16_t group, uint16_t element) @@ -1097,7 +1097,7 @@ void* gdcmDocument::LoadEntryVoidArea(uint16_t group, uint16_t elem) size_t o =(size_t)docElement->GetOffset(); fseek(Fp, o, SEEK_SET); size_t l = docElement->GetLength(); - char* a = new char[l]; + uint8_t* a = new uint8_t[l]; if(!a) { dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea cannot allocate a"); @@ -1126,13 +1126,13 @@ void *gdcmDocument::LoadEntryVoidArea(gdcmBinEntry *element) size_t o =(size_t)element->GetOffset(); fseek(Fp, o, SEEK_SET); size_t l = element->GetLength(); - char* a = new char[l]; + uint8_t* a = new uint8_t[l]; if( !a ) { dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea cannot allocate a"); return NULL; } - element->SetVoidArea((void *)a); + element->SetVoidArea((uint8_t*)a); /// \todo check the result size_t l2 = fread(a, 1, l , Fp); if( l != l2 ) @@ -1151,7 +1151,7 @@ void *gdcmDocument::LoadEntryVoidArea(gdcmBinEntry *element) * @param element Element number of the searched Dicom Element * @return */ -bool gdcmDocument::SetEntryVoidAreaByNumber(void * area, +bool gdcmDocument::SetEntryVoidAreaByNumber(uint8_t* area, uint16_t group, uint16_t element) { diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 9923076d..995575f9 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2004/09/20 18:14:23 $ - Version: $Revision: 1.39 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -136,7 +136,7 @@ public: uint16_t group, uint16_t elem, std::string const & VR ="unkn"); - gdcmBinEntry* ReplaceOrCreateByNumber(void *voidArea, int lgth, + gdcmBinEntry* ReplaceOrCreateByNumber(uint8_t* voidArea, int lgth, uint16_t group, uint16_t elem, std::string const & VR="unkn"); @@ -177,14 +177,14 @@ public: std::string const & tagName); virtual bool SetEntryByNumber(std::string const & content, uint16_t group, uint16_t element); - virtual bool SetEntryByNumber(void *content, int lgth, + virtual bool SetEntryByNumber(uint8_t* content, int lgth, uint16_t group, uint16_t element); virtual bool SetEntryLengthByNumber(uint32_t length, uint16_t group, uint16_t element); virtual size_t GetEntryOffsetByNumber (uint16_t group, uint16_t elem); virtual void* GetEntryVoidAreaByNumber(uint16_t group, uint16_t elem); - virtual bool SetEntryVoidAreaByNumber(void* a, uint16_t group, + virtual bool SetEntryVoidAreaByNumber(uint8_t* a, uint16_t group, uint16_t elem); virtual void UpdateShaEntries(); diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 18e2d7d0..75bdc905 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/09/20 18:14:23 $ - Version: $Revision: 1.126 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.127 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -352,7 +352,7 @@ void gdcmFile::SetPixelDataSizeFromHeader() * @return Pointer to newly allocated pixel data. * NULL if alloc fails */ -void *gdcmFile::GetImageData() +uint8_t* gdcmFile::GetImageData() { // FIXME (Mathieu) // I need to deallocate Pixel_Data before doing any allocation: @@ -477,7 +477,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) * @return Pointer to newly allocated pixel data. * \ NULL if alloc fails */ -void * gdcmFile::GetImageDataRaw () +uint8_t* gdcmFile::GetImageDataRaw () { size_t imgDataSize; if ( Header->HasLUT() ) @@ -821,7 +821,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void *destination, size_t maxSize) * * @return boolean */ -bool gdcmFile::SetImageData(void *inData, size_t expectedSize) +bool gdcmFile::SetImageData(uint8_t* inData, size_t expectedSize) { Header->SetImageDataSize( expectedSize ); // FIXME : if already allocated, memory leak ! diff --git a/src/gdcmFile.h b/src/gdcmFile.h index a1558cf2..682d5bb1 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2004/09/20 18:14:23 $ - Version: $Revision: 1.49 $ + Date: $Date: 2004/09/23 09:40:30 $ + Version: $Revision: 1.50 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -53,9 +53,9 @@ public: /// -the (vtk) user is supposed to know how to deal with LUTs- size_t GetImageDataSizeRaw(){ return ImageDataSizeRaw; }; - void * GetImageData(); + uint8_t* GetImageData(); size_t GetImageDataIntoVector(void* destination, size_t maxSize); - void * GetImageDataRaw(); + uint8_t* GetImageDataRaw(); size_t GetImageDataIntoVectorRaw(void* destination, size_t maxSize); // Allocates ExpectedSize bytes of memory at this->Data and copies the @@ -65,7 +65,7 @@ public: // e.g. VTK) before calling the Write // see also gdcmHeader::SetImageDataSize ?!? - bool SetImageData (void * data, size_t expectedSize); + bool SetImageData (uint8_t* data, size_t expectedSize); /// \todo When the caller is aware we simply point to the data: /// int SetImageDataNoCopy (void * Data, size_t ExpectedSize); @@ -143,7 +143,7 @@ private: // /// \brief to hold the Pixels (when read) - void* Pixel_Data; // (was PixelData) + uint8_t* Pixel_Data; // (was PixelData) /// \brief Area length to receive the Gray Level pixels size_t ImageDataSizeRaw;