]> Creatis software - gdcm.git/commitdiff
2004-09-23 Jean-Pierre Roux
authorjpr <jpr>
Thu, 23 Sep 2004 09:40:28 +0000 (09:40 +0000)
committerjpr <jpr>
Thu, 23 Sep 2004 09:40:28 +0000 (09:40 +0000)
  * 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

13 files changed:
ChangeLog
Example/TestCopyDicom.cxx
Example/TestReadWriteReadCompare.cxx
Example/TestWriteSimple.cxx
Example/WriteDicom.cxx
Testing/TestCopyDicom.cxx
Testing/TestReadWriteReadCompare.cxx
src/gdcmBinEntry.cxx
src/gdcmBinEntry.h
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmFile.cxx
src/gdcmFile.h

index b825eda10eadfbaac73ed4d3b23e7f4f5738ce39..e09e4ba1731260a8aa1673d629bfe27644032359 100644 (file)
--- 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 <Eric.Boix@creatis.insa-lyon.fr>
   * src/gdcmDocument.cxx: gdcmDocument::~gdcmDocument() doesn't clear (nor
     clear) TagHT, which is an inherited member of gdcmElementSet. It is
index bfc92b8a0279605f9e68a4332c56080e1f66e70b..092e6f16c5c6f73ab933adff89fb9e9a006c8639 100644 (file)
@@ -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
   
index da97003a0d5b9533aa9fe5e7fcb4559b3f556dc8..3732918a9882f83d04fa065881b642834c14d030 100644 (file)
@@ -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) 
index df717bf4299b69e10d65954d912cec968b9c9f0f..379658695c0300789dffb6a0bc666b4c86f05d77 100644 (file)
@@ -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);
 
index 10554b397504a641e0c5a763c48dd771af8c19d8..18d798fd10bc39011fce5a5ff053c8dfff9af4a0 100644 (file)
@@ -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;
 
index 2a2416ec647ff0dcf76d1c379dafdc4d7e3cb229..8bbedf69aea75e703041838331052a6ab270060c 100644 (file)
@@ -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
   
index ac868dcdc254e529f576cf3c843fa9578f3f99fc..d3eb11b507c454289cb017e33571ad48acb4a954 100644 (file)
@@ -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) 
index 092c1ee18cd14d6407e7b2cb12ad41f4b354a441..47af8c38888458dcebd528afb2c88285982be9e6 100644 (file)
@@ -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;  
 }
 
index bbc8451d3eea29d798f4d58a4528018d12cc0845..c013ee1408ff768766fd6fa8c0168a07307f7053 100644 (file)
@@ -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;
 
 };
 
index 5ee4e61a0c81513e26dcb9ccdf47cd571ff0489d..5e529a5aee33d8fe53c00184577e75f1f40fe379 100644 (file)
@@ -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) 
 {
index 9923076d19105e593a1800a2ccdc7fbc278f01dd..995575f9c8dc6fcb9cbf0e8d9705f632018dbdbb 100644 (file)
@@ -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();
index 18e2d7d07d68ff56b23200cf9e0b0766850d0728..75bdc905d5c1caf5b6d7d007a4ff8e269122e5d8 100644 (file)
@@ -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 !
index a1558cf2d5b41ce94b0b5afa541d897049c8bf2f..682d5bb107698b85ef9787131910f271fb4dafb0 100644 (file)
@@ -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;