if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
// we get current directory name
- char*dummy=(char*) malloc(1000);
- getcwd(dummy,(size_t)1000);
+ char* dummy= new char[1000];
+ getcwd(dummy, (size_t)1000);
SetFileName(dummy); // will be converted into a string
- free(dummy); // no longer needed
+ delete[] dummy; // no longer needed
}
if(parseDir)
return(false);
}
- char * filePreamble;
- filePreamble=(char*)calloc(128,1);
+ char * filePreamble = new char[128];
fwrite(filePreamble,128,1,fp1);
fwrite("DICM",4,1,fp1);
- free(filePreamble);
+ delete[] filePreamble;
UpdateDirectoryRecordSequenceLength();
WriteEntries(fp1);
* NULL if alloc fails
*/
void * gdcmFile::GetImageData (void) {
- PixelData = (void *) malloc(lgrTotale);
+ PixelData = new char[lgrTotale];
if (PixelData)
GetImageDataIntoVector(PixelData, lgrTotale);
return lgrTotale;
// from Lut R + Lut G + Lut B
- unsigned char * newDest = (unsigned char *)malloc(lgrTotale);
+ unsigned char * newDest = new (unsigned char)[lgrTotale];
unsigned char * a = (unsigned char *)destination;
unsigned char * lutRGBA = Header->GetLUTRGBA();
if (lutRGBA) {
*a++ = lutRGBA[j+1];
*a++ = lutRGBA[j+2];
}
- free(newDest);
+ delete[] newDest;
// now, it's an RGB image
// Lets's write it in the Header
lgrTotale /= 3; // TODO Let gdcmHeadar user a chance
// to get the right value
// Create a member lgrTotaleRaw ???
- PixelData = (void *) malloc(lgrTotale);
+ PixelData = new char[lgrTotale];
if (PixelData)
GetImageDataIntoVectorRaw(PixelData, lgrTotale);
PixelRead=1; // PixelRaw
int l = Header->GetXSize()*Header->GetYSize();
int nbFrames = Header->GetZSize();
- unsigned char * newDest = (unsigned char*) malloc(lgrTotale);
+ unsigned char * newDest = new (unsigned char)[lgrTotale];
unsigned char *x = newDest;
unsigned char * a = (unsigned char *)destination;
unsigned char * b = a + l;
}
}
memmove(destination,newDest,lgrTotale);
- free(newDest);
+ delete[] newDest;
} else {
int l = Header->GetXSize()*Header->GetYSize()*Header->GetZSize();
- char * newDest = (char*) malloc(lgrTotale);
+ char * newDest = new char[lgrTotale];
char * x = newDest;
char * a = (char *)destination;
char * b = a + l;
*(x++) = *(c++);
}
memmove(destination,newDest,lgrTotale);
- free(newDest);
+ delete[] newDest;
}
break;
}
if ( (type == ImplicitVR) || (type == ExplicitVR) ) {
char * filePreamble;
// writing Dicom File Preamble
- filePreamble=(char*)calloc(128,1);
+ filePreamble=new char[128];
fwrite(filePreamble,128,1,fp1);
fwrite("DICM",4,1,fp1);
- free (filePreamble);
+ delete[] filePreamble;
}
// --------------------------------------------------------------
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);
}
}
// forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT
- unsigned char *LUTRGBA = (unsigned char *)calloc(1024,1); // 256 * 4 (R, G, B, Alpha)
+ unsigned char *LUTRGBA = new (unsigned char)[1024]; // 256 * 4 (R, G, B, Alpha)
if (!LUTRGBA) {
return NULL;
}
(unsigned)ftellRes,ln,ln);
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){
(unsigned)ftellRes,ln,ln);
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){
size_t o =(size_t)Element->GetOffset();
fseek(fp, o, SEEK_SET);
size_t l=Element->GetLength();
- void * a = malloc(l);
+ char* a = new char[l];
if(!a)
return NULL;
size_t l2 = fread(a, 1, l ,fp);
if(l != l2)
{
- free(a);
+ delete[] a;
return NULL;
}
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){
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;
}
}
memmove(image_buffer,newDest,lgrTotale);
- free(newDest);
+ delete[] newDest;
}
return(true);