change some free/malloc's back to delete/new's

This commit is contained in:
jacob1
2013-01-12 21:06:52 -05:00
parent 0b6418b78d
commit 41751da619
4 changed files with 109 additions and 111 deletions

View File

@@ -286,7 +286,7 @@ std::vector<char> GameSave::Serialise()
int dataSize;
char * data = Serialise(dataSize);
std::vector<char> dataVect(data, data+dataSize);
free(data);
delete data;
return dataVect;
}
@@ -2004,7 +2004,7 @@ char * GameSave::serialiseOPS(int & dataLength)
finalData = (unsigned char *)bson_data(&b);
finalDataLen = bson_size(&b);
outputDataLen = finalDataLen*2+12;
outputData = (unsigned char *)malloc(outputDataLen);
outputData = new unsigned char[outputDataLen];
outputData[0] = 'O';
outputData[1] = 'P';

View File

@@ -284,7 +284,7 @@ pixel *Graphics::resample_img_nn(pixel * src, int sw, int sh, int rw, int rh)
{
int y, x;
pixel *q = NULL;
q = (pixel *)malloc(rw*rh*PIXELSIZE);
q = new pixel[rw*rh];
for (y=0; y<rh; y++)
for (x=0; x<rw; x++){
q[rw*y+x] = src[sw*(y*sh/rh)+(x*sw/rw)];
@@ -317,8 +317,8 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
samples[i] = new float[sourceWidth];
}
unsigned char * resultImage = (unsigned char*)malloc((resultHeight * resultPitch) * sizeof(unsigned char));
memset(resultImage, 0, (resultHeight * resultPitch) * sizeof(unsigned char));
unsigned char * resultImage = new unsigned char[resultHeight * resultPitch];
std::fill(resultImage, resultImage + (resultHeight*resultPitch), 0);
//Resample time
int resultY = 0;

View File

@@ -411,7 +411,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
float factorY = ((float)YRES/2)/((float)savePreview->Size.Y);
float scaleFactor = factorY < factorX ? factorY : factorX;
savePreview->Data = Graphics::resample_img(oldData, savePreview->Size.X, savePreview->Size.Y, savePreview->Size.X*scaleFactor, savePreview->Size.Y*scaleFactor);
free(oldData);
delete oldData;
savePreview->Size.X *= scaleFactor;
savePreview->Size.Y *= scaleFactor;
}

View File

@@ -16,7 +16,7 @@ Thumbnail::Thumbnail(const Thumbnail & thumb):
//Ensure the actual thumbnail data is copied
if(thumb.Data)
{
Data = (pixel *)malloc((thumb.Size.X*thumb.Size.Y) * PIXELSIZE);
Data = new pixel[thumb.Size.X*thumb.Size.Y];
memcpy(Data, thumb.Data, (thumb.Size.X*thumb.Size.Y) * PIXELSIZE);
}
else
@@ -33,7 +33,7 @@ Thumbnail::Thumbnail(int _id, int _datestamp, pixel * _data, ui::Point _size):
{
if(_data)
{
Data = (pixel *)malloc((_size.X*_size.Y) * PIXELSIZE);
Data = new pixel[_size.X*_size.Y];
memcpy(Data, _data, (_size.X*_size.Y) * PIXELSIZE);
}
else
@@ -69,14 +69,12 @@ void Thumbnail::Resize(ui::Point newSize)
Data = Graphics::resample_img(thumbData, Size.X, Size.Y, Size.X * scaleFactor, Size.Y * scaleFactor);
Size.X *= scaleFactor;
Size.Y *= scaleFactor;
free(thumbData);
delete thumbData;
}
}
Thumbnail::~Thumbnail()
{
if(Data)
{
free(Data);
}
delete Data;
}