]> Creatis software - gdcm.git/blobdiff - src/gdcmRLE.cxx
Fix warnings, add a GDCM_DATA_ROOT to CMake
[gdcm.git] / src / gdcmRLE.cxx
index 4387ebcfd78bb1460a1b434c9c886a81399184ab..14f2431c5b465a0976d14c78facfcbcd9bda39e7 100644 (file)
@@ -2,7 +2,7 @@
 //-----------------------------------------------------------------------------
 #include <stdio.h>
 #include "gdcmFile.h"
-#include <ctype.h>             /* to declare isprint() */
+#include <ctype.h>             // to declare isprint()
 
 #define str2num(str, typeNum) *((typeNum *)(str))
 
@@ -12,8 +12,7 @@
  * \brief     Reads a 'Run Length Encoded' Dicom encapsulated file
  * @param     fp already open File Pointer
  * @param     image_buffer destination Address (in caller's memory space) 
- *            at which the pixel data should be copied
- *   
+ *            at which the pixel data should be copied 
  * @return    Boolean 
  */
 bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
@@ -42,7 +41,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       ln=Header->SwapLong(ln);    // Basic Offset Table Item Lentgh
    if (ln != 0) {
       // What is it used for ??
-      char * BasicOffsetTableItemValue= (char *)malloc(ln+1);
+      char * BasicOffsetTableItemValue= new char[ln+1];
       fread(BasicOffsetTableItemValue,ln,1,fp); 
       guint32 a;
       for (int i=0;i<ln;i+=4){
@@ -80,7 +79,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       }
 
       if (nbRleSegments>1) { 
-         for(int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments
+         for(unsigned int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments
             RleSegmentLength[k]=RleSegmentOffsetTable[k+1]-RleSegmentOffsetTable[k];
             ftellRes=ftell(fp);
             fragmentBegining=ftell(fp);   
@@ -115,7 +114,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
       int l = Header->GetXSize()*Header->GetYSize();
       int nbFrames = Header->GetZSize();
 
-      char * newDest = (char*) malloc(l*nbFrames*2);
+      char * newDest = new char[l*nbFrames*2];
       char *x  = newDest;
       char * a = (char *)image_buffer;
       char * b = a + l;
@@ -127,7 +126,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
          }
       }
       memmove(image_buffer,newDest,lgrTotale);
-      free(newDest);   
+      delete[] newDest;
    }
       
    return(true);
@@ -138,6 +137,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) {
 // RLE LossLess Fragment
 int gdcmFile::gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode, 
                                      long uncompressedSegmentSize, FILE *fp) {
+        (void)lengthToDecode;  //FIXME
    long ftellRes;
    int count;
    long numberOfOutputBytes=0;