diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-16 16:32:48 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-16 16:32:48 +0400 |
commit | 3bc16fd60dd573f8289552a0046b0735d1c7e02b (patch) | |
tree | 3936a357fd922e96b622f29f04804b20cb11f234 /source | |
parent | 883e9df1ccdaaa847c86e2d1457fd88333b87c84 (diff) |
compositor: replace C++ new/delete with guardedalloc.
Diffstat (limited to 'source')
16 files changed, 88 insertions, 78 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 9a80c5e82ae..97afb7b6bc3 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -38,6 +38,7 @@ #include "COM_ChunkOrder.h" #include "COM_ExecutionSystemHelper.h" +#include "MEM_guardedalloc.h" #include "BLI_math.h" #include "PIL_time.h" #include "WM_api.h" @@ -148,14 +149,14 @@ NodeOperation *ExecutionGroup::getOutputNodeOperation() const void ExecutionGroup::initExecution() { if (this->m_chunkExecutionStates != NULL) { - delete[] this->m_chunkExecutionStates; + MEM_freeN(this->m_chunkExecutionStates); } unsigned int index; determineNumberOfChunks(); this->m_chunkExecutionStates = NULL; if (this->m_numberOfChunks != 0) { - this->m_chunkExecutionStates = new ChunkExecutionState[this->m_numberOfChunks]; + this->m_chunkExecutionStates = (ChunkExecutionState *)MEM_mallocN(sizeof(ChunkExecutionState) * this->m_numberOfChunks, __func__); for (index = 0; index < this->m_numberOfChunks; index++) { this->m_chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED; } @@ -180,7 +181,7 @@ void ExecutionGroup::initExecution() void ExecutionGroup::deinitExecution() { if (this->m_chunkExecutionStates != NULL) { - delete[] this->m_chunkExecutionStates; + MEM_freeN(this->m_chunkExecutionStates); this->m_chunkExecutionStates = NULL; } this->m_numberOfChunks = 0; @@ -227,7 +228,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) this->m_chunksFinished = 0; this->m_bTree = bTree; unsigned int index; - unsigned int *chunkOrder = new unsigned int[this->m_numberOfChunks]; + unsigned int *chunkOrder = (unsigned int *)MEM_mallocN(sizeof(unsigned int) * this->m_numberOfChunks, __func__); for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) { chunkOrder[chunkNumber] = chunkNumber; @@ -256,10 +257,10 @@ void ExecutionGroup::execute(ExecutionSystem *graph) break; case COM_TO_CENTER_OUT: { - ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[1]; + ChunkOrderHotspot *hotspots[1]; hotspots[0] = new ChunkOrderHotspot(this->m_width * centerX, this->m_height * centerY, 0.0f); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_numberOfChunks, __func__); for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); @@ -274,13 +275,12 @@ void ExecutionGroup::execute(ExecutionSystem *graph) } delete hotspots[0]; - delete[] hotspots; - delete[] chunkOrders; + MEM_freeN(chunkOrders); } break; case COM_TO_RULE_OF_THIRDS: { - ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[9]; + ChunkOrderHotspot *hotspots[9]; unsigned int tx = this->m_width / 6; unsigned int ty = this->m_height / 6; unsigned int mx = this->m_width / 2; @@ -299,7 +299,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7); hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_numberOfChunks, __func__); for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); @@ -323,8 +323,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) delete hotspots[6]; delete hotspots[7]; delete hotspots[8]; - delete[] hotspots; - delete[] chunkOrders; + MEM_freeN(chunkOrders); } break; case COM_TO_TOP_DOWN: @@ -372,7 +371,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) } } - delete[] chunkOrder; + MEM_freeN(chunkOrder); } MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) @@ -383,10 +382,7 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) determineChunkRect(&rect, chunkNumber); this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; - for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { - memoryBuffers[index] = NULL; - } + MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(sizeof(MemoryBuffer *) * this->m_cachedMaxReadBufferOffset, __func__); rcti output; for (index = 0; index < this->m_cachedReadOperations.size(); index++) { ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; @@ -422,7 +418,7 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo } } } - delete[] memoryBuffers; + MEM_freeN(memoryBuffers); } if (this->m_bTree) { // status report is only performed for top level Execution Groups. diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index d227f9cc4bb..ee1c0320f5f 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -75,7 +75,7 @@ float *MemoryBuffer::convertToValueBuffer() const unsigned int size = this->determineBufferSize(); unsigned int i; - float *result = new float[size]; + float *result = (float *)MEM_mallocN(sizeof(float) * size, __func__); const float *fp_src = this->m_buffer; float *fp_dst = result; diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 61b18a6daf4..dcec228a6b7 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -32,6 +32,8 @@ #include "OCL_opencl.h" #include "COM_WriteBufferOperation.h" +#include "MEM_guardedalloc.h" + #include "PIL_time.h" #include "BLI_threads.h" @@ -99,20 +101,20 @@ void **g_highlightedNodesRead; void COM_startReadHighlights() { if (g_highlightedNodesRead) { - delete [] g_highlightedNodesRead; + MEM_freeN(g_highlightedNodesRead); } g_highlightedNodesRead = g_highlightedNodes; - g_highlightedNodes = new void *[MAX_HIGHLIGHT]; + g_highlightedNodes = (void **)MEM_callocN(sizeof(void *) * MAX_HIGHLIGHT, __func__); g_highlightIndex = 0; - for (int i = 0 ; i < MAX_HIGHLIGHT; i++) { - g_highlightedNodes[i] = 0; - } } int COM_isHighlightedbNode(bNode *bnode) { - if (!g_highlightedNodesRead) return false; + if (!g_highlightedNodesRead) { + return false; + } + for (int i = 0 ; i < MAX_HIGHLIGHT; i++) { void *p = g_highlightedNodesRead[i]; if (!p) return false; @@ -255,8 +257,8 @@ extern void clContextError(const char *errinfo, const void *private_info, size_t void WorkScheduler::initialize() { - g_highlightedNodesRead = 0; - g_highlightedNodes = 0; + g_highlightedNodesRead = NULL; + g_highlightedNodes = NULL; COM_startReadHighlights(); #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE int numberOfCPUThreads = BLI_system_thread_count(); @@ -275,7 +277,7 @@ void WorkScheduler::initialize() error = clGetPlatformIDs(0, 0, &numberOfPlatforms); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } if (G.f & G_DEBUG) printf("%d number of platforms\n", numberOfPlatforms); - cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms]; + cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(sizeof(cl_platform_id) * numberOfPlatforms, __func__); error = clGetPlatformIDs(numberOfPlatforms, platforms, 0); unsigned int indexPlatform; for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { @@ -283,7 +285,7 @@ void WorkScheduler::initialize() cl_uint numberOfDevices = 0; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); if (numberOfDevices > 0) { - cl_device_id *cldevices = new cl_device_id[numberOfDevices]; + cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(sizeof(cl_device_id) * numberOfDevices, __func__); clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0); g_context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); @@ -297,12 +299,12 @@ void WorkScheduler::initialize() printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - char *build_log = new char[ret_val_size + 1]; + char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__); error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } build_log[ret_val_size] = '\0'; printf("%s", build_log); - delete build_log; + MEM_freeN(build_log); } else { unsigned int indexDevices; @@ -316,10 +318,10 @@ void WorkScheduler::initialize() g_gpudevices.push_back(clDevice); } } - delete[] cldevices; + MEM_freeN(cldevices); } } - delete[] platforms; + MEM_freeN(platforms); } #endif #endif diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp index 12bf651992e..c37830a9d92 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp @@ -23,6 +23,10 @@ #include "COM_AntiAliasOperation.h" #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BKE_utildefines.h" + +#include "MEM_guardedalloc.h" + extern "C" { #include "RE_render_ext.h" } @@ -58,7 +62,7 @@ void AntiAliasOperation::deinitExecution() { this->m_valueReader = NULL; if (this->m_buffer) { - delete this->m_buffer; + MEM_freeN(this->m_buffer); } NodeOperation::deinitMutex(); } @@ -90,12 +94,10 @@ void *AntiAliasOperation::initializeTileData(rcti *rect) MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect); int size = tile->getHeight() * tile->getWidth(); float *input = tile->getBuffer(); - char *valuebuffer = new char[size]; + char *valuebuffer = (char *)MEM_mallocN(sizeof(char) * size, __func__); for (int i = 0; i < size; i++) { float in = input[i * COM_NUMBER_OF_CHANNELS]; - if (in < 0.0f) { in = 0.0f; } - if (in > 1.0f) {in = 1.0f; } - valuebuffer[i] = in * 255; + valuebuffer[i] = FTOCHAR(in); } antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer); this->m_buffer = valuebuffer; diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index 98aeba41ecb..c527807f839 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -22,6 +22,7 @@ #include "COM_BlurBaseOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" extern "C" { #include "RE_pipeline.h" @@ -74,7 +75,7 @@ float *BlurBaseOperation::make_gausstab(int rad) n = 2 * rad + 1; - gausstab = new float[n]; + gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__); sum = 0.0f; for (i = -rad; i <= rad; i++) { @@ -99,7 +100,7 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) n = 2 * rad + 1; - dist_fac_invert = new float[n]; + dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__); for (i = -rad; i <= rad; i++) { val = 1.0f - fabsf(((float)i / (float)rad)); diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp index fd593b39dcd..553a9827ffa 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp @@ -24,6 +24,8 @@ #include "BLI_utildefines.h" +#include "MEM_guardedalloc.h" + ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); @@ -42,7 +44,7 @@ void ConvolutionFilterOperation::initExecution() void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9) { - this->m_filter = new float[9]; + this->m_filter = (float *)MEM_mallocN(sizeof(float) * 9, __func__); this->m_filter[0] = f1; this->m_filter[1] = f2; this->m_filter[2] = f3; @@ -61,7 +63,7 @@ void ConvolutionFilterOperation::deinitExecution() this->m_inputOperation = NULL; this->m_inputValueOperation = NULL; if (this->m_filter) { - delete[] this->m_filter; + MEM_freeN(this->m_filter); this->m_filter = NULL; } } diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 5e70187557b..2687fee28ce 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -24,6 +24,8 @@ #include "BLI_math.h" #include "COM_OpenCLDevice.h" +#include "MEM_guardedalloc.h" + // DilateErode Distance Threshold DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() { @@ -384,7 +386,7 @@ void DilateStepOperation::deinitExecution() this->m_inputProgram = NULL; this->deinitMutex(); if (this->m_cached_buffer) { - delete [] this->m_cached_buffer; + MEM_freeN(this->m_cached_buffer); this->m_cached_buffer = NULL; } } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index d5daace059d..39665b10f48 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1269,12 +1269,12 @@ void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect) if (this->m_cachedInstance == NULL) { MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect); MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect); - float *data = new float[this->getWidth() * this->getHeight()]; + float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(), __func__); float *imask = innerMask->convertToValueBuffer(); float *omask = outerMask->convertToValueBuffer(); doDoubleEdgeMask(imask, omask, data); - delete [] imask; - delete [] omask; + MEM_freeN(imask); + MEM_freeN(omask); this->m_cachedInstance = data; } unlockMutex(); @@ -1293,7 +1293,7 @@ void DoubleEdgeMaskOperation::deinitExecution() this->m_inputOuterMask = NULL; deinitMutex(); if (this->m_cachedInstance) { - delete this->m_cachedInstance; + MEM_freeN(this->m_cachedInstance); this->m_cachedInstance = NULL; } } diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp index 935bfcac6c7..82f38556e82 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -23,6 +23,7 @@ #include "COM_GaussianAlphaXBlurOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" extern "C" { #include "RE_pipeline.h" @@ -154,9 +155,9 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo void GaussianAlphaXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->m_gausstab; + MEM_freeN(this->m_gausstab); this->m_gausstab = NULL; - delete [] this->m_distbuf_inv; + MEM_freeN(this->m_distbuf_inv); this->m_distbuf_inv = NULL; deinitMutex(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index 375f1bcf07c..bfd9564817e 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -23,6 +23,7 @@ #include "COM_GaussianAlphaYBlurOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" extern "C" { #include "RE_pipeline.h" @@ -154,9 +155,9 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo void GaussianAlphaYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->m_gausstab; + MEM_freeN(this->m_gausstab); this->m_gausstab = NULL; - delete [] this->m_distbuf_inv; + MEM_freeN(this->m_distbuf_inv); this->m_distbuf_inv = NULL; deinitMutex(); diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index d97d2f15ded..a9bcb2dd752 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -88,7 +88,7 @@ void GaussianBokehBlurOperation::updateGauss() n = (2 * this->m_radx + 1) * (2 * this->m_rady + 1); /* create a full filter image */ - ddgauss = new float[n]; + ddgauss = (float *)MEM_mallocN(sizeof(float) * n, __func__); dgauss = ddgauss; val = 0.0f; for (j = -this->m_rady; j <= this->m_rady; j++) { @@ -103,8 +103,9 @@ void GaussianBokehBlurOperation::updateGauss() } if (val != 0.0f) { val = 1.0f / val; - for (j = n - 1; j >= 0; j--) + for (j = n - 1; j >= 0; j--) { ddgauss[j] *= val; + } } else ddgauss[4] = 1.0f; @@ -158,7 +159,7 @@ void GaussianBokehBlurOperation::executePixel(float output[4], int x, int y, voi void GaussianBokehBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->m_gausstab; + MEM_freeN(this->m_gausstab); this->m_gausstab = NULL; deinitMutex(); @@ -258,8 +259,9 @@ void GaussianBlurReferenceOperation::updateGauss() int i; int x = MAX2(m_radx, m_rady); this->m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array"); - for (i = 0; i < x; i++) + for (i = 0; i < x; i++) { m_maintabs[i] = make_gausstab(i + 1); + } } void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y, void *data) @@ -326,8 +328,9 @@ void GaussianBlurReferenceOperation::deinitExecution() { int x, i; x = MAX2(m_radx, m_rady); - for (i = 0; i < x; i++) - delete []m_maintabs[i]; + for (i = 0; i < x; i++) { + MEM_freeN(m_maintabs[i]); + } MEM_freeN(m_maintabs); BlurBaseOperation::deinitExecution(); } diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 01c85738822..984119b926a 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -22,6 +22,7 @@ #include "COM_GaussianXBlurOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" extern "C" { #include "RE_pipeline.h" @@ -107,7 +108,7 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d void GaussianXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->m_gausstab; + MEM_freeN(this->m_gausstab); this->m_gausstab = NULL; deinitMutex(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index 298b4660c6a..192bc29e1ae 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -22,6 +22,7 @@ #include "COM_GaussianYBlurOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" extern "C" { #include "RE_pipeline.h" @@ -108,7 +109,7 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d void GaussianYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->m_gausstab; + MEM_freeN(this->m_gausstab); this->m_gausstab = NULL; deinitMutex(); diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index 9ce682ffe49..bfc0ecd1c00 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -121,7 +121,7 @@ void InpaintSimpleOperation::calc_manhatten_distance() { int width = this->getWidth(); int height = this->getHeight(); - short *m = this->m_manhatten_distance = new short[width * height]; + short *m = this->m_manhatten_distance = (short *)MEM_mallocN(sizeof(short) * width * height, __func__); int *offsets; offsets = (int *)MEM_callocN(sizeof(int) * (width + height + 1), "InpaintSimpleOperation offsets"); @@ -163,7 +163,7 @@ void InpaintSimpleOperation::calc_manhatten_distance() } this->m_area_size = offsets[width + height]; - this->m_pixelorder = new int[this->m_area_size]; + this->m_pixelorder = (int *)MEM_mallocN(sizeof(int) * this->m_area_size, __func__); for (int i = 0; i < width * height; i++) { if (m[i] > 0) { @@ -224,9 +224,7 @@ void *InpaintSimpleOperation::initializeTileData(rcti *rect) lockMutex(); if (!this->m_cached_buffer_ready) { MemoryBuffer *buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect); - - this->m_cached_buffer = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS]; - memcpy(this->m_cached_buffer, buf->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + this->m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer()); this->calc_manhatten_distance(); @@ -255,17 +253,17 @@ void InpaintSimpleOperation::deinitExecution() this->m_inputImageProgram = NULL; this->deinitMutex(); if (this->m_cached_buffer) { - delete [] this->m_cached_buffer; + MEM_freeN(this->m_cached_buffer); this->m_cached_buffer = NULL; } if (this->m_pixelorder) { - delete [] this->m_pixelorder; + MEM_freeN(this->m_pixelorder); this->m_pixelorder = NULL; } if (this->m_manhatten_distance) { - delete [] this->m_manhatten_distance; + MEM_freeN(this->m_manhatten_distance); this->m_manhatten_distance = NULL; } this->m_cached_buffer_ready = false; diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index 00723d92a84..7e62de7b9f1 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -25,6 +25,8 @@ #include "COM_NodeOperation.h" #include "DNA_movieclip_types.h" +#include "MEM_guardedalloc.h" + extern "C" { #include "BKE_tracking.h" #include "PIL_time.h" @@ -62,22 +64,19 @@ public: this->m_calibration_width = calibration_width; this->m_calibration_height = calibration_height; this->m_inverted = inverted; - this->m_bufferCalculated = new int[this->m_width * this->m_height]; - this->m_buffer = new float[this->m_width * this->m_height * 2]; - for (int i = 0; i < this->m_width * this->m_height; i++) { - this->m_bufferCalculated[i] = 0; - } + this->m_bufferCalculated = (int *)MEM_callocN(sizeof(int) * this->m_width * this->m_height, __func__); + this->m_buffer = (float *)MEM_mallocN(sizeof(float) * this->m_width * this->m_height * 2, __func__); this->updateLastUsage(); } ~DistortionCache() { if (this->m_buffer) { - delete[] this->m_buffer; + MEM_freeN(this->m_buffer); this->m_buffer = NULL; } if (this->m_bufferCalculated) { - delete[] this->m_bufferCalculated; + MEM_freeN(this->m_bufferCalculated); this->m_bufferCalculated = NULL; } } diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index ebf3b772b3b..08ef1249a6a 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -23,6 +23,8 @@ #include "COM_VectorBlurOperation.h" #include "BLI_math.h" +#include "MEM_guardedalloc.h" + // use the implementation of blender internal renderer to calculate the vector blur. extern "C" { #include "RE_pipeline.h" @@ -66,7 +68,7 @@ void VectorBlurOperation::deinitExecution() this->m_inputSpeedProgram = NULL; this->m_inputZProgram = NULL; if (this->m_cachedInstance) { - delete [] this->m_cachedInstance; + MEM_freeN(this->m_cachedInstance); this->m_cachedInstance = NULL; } } @@ -81,8 +83,7 @@ void *VectorBlurOperation::initializeTileData(rcti *rect) MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect); MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect); MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect); - float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS]; - memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + float *data = (float *)MEM_dupallocN(tile->getBuffer()); this->generateVectorBlur(data, tile, speed, z); this->m_cachedInstance = data; } @@ -115,6 +116,6 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma blurdata.curved = this->m_settings->curved; blurdata.fac = this->m_settings->fac; RE_zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), zbuf); - delete [] zbuf; + MEM_freeN((void *)zbuf); return; } |