From 25bd58a533fda08e8da978fbf2ca487034c0e02c Mon Sep 17 00:00:00 2001 From: xy Date: Thu, 27 Oct 2011 08:00:02 +0800 Subject: [PATCH] Fix incorrect constructor. Use malloc instead of realloc. --- src/subtitles/Rasterizer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/subtitles/Rasterizer.cpp b/src/subtitles/Rasterizer.cpp index 1c8b608..817e663 100644 --- a/src/subtitles/Rasterizer.cpp +++ b/src/subtitles/Rasterizer.cpp @@ -1670,16 +1670,15 @@ PathData::PathData():mpPathTypes(NULL), mpPathPoints(NULL), mPathPoints(0) { } -PathData::PathData( const PathData& src ) +PathData::PathData( const PathData& src ):mPathPoints(src.mPathPoints) { //TODO: deal with the case that src.mPathPoints<0 - if(mPathPoints!=src.mPathPoints && src.mPathPoints>0) + if(mPathPoints>0) { - mPathPoints = src.mPathPoints; - mpPathTypes = (BYTE*)realloc(mpPathTypes, mPathPoints * sizeof(BYTE)); - mpPathPoints = (POINT*)realloc(mpPathPoints, mPathPoints * sizeof(POINT)); + mpPathTypes = static_cast(malloc(mPathPoints * sizeof(BYTE))); + mpPathPoints = static_cast(malloc(mPathPoints * sizeof(POINT))); } - if(src.mPathPoints>0) + if(mPathPoints>0) { memcpy(mpPathTypes, src.mpPathTypes, mPathPoints*sizeof(BYTE)); memcpy(mpPathPoints, src.mpPathPoints, mPathPoints*sizeof(POINT)); @@ -1693,8 +1692,10 @@ const PathData& PathData::operator=( const PathData& src ) if(mPathPoints!=src.mPathPoints && src.mPathPoints>0) { mPathPoints = src.mPathPoints; - mpPathTypes = (BYTE*)realloc(mpPathTypes, mPathPoints * sizeof(BYTE)); - mpPathPoints = (POINT*)realloc(mpPathPoints, mPathPoints * sizeof(POINT)); + delete[] mpPathTypes; + delete[] mpPathPoints; + mpPathTypes = static_cast(malloc(mPathPoints * sizeof(BYTE))); + mpPathPoints = static_cast(malloc(mPathPoints * sizeof(POINT)));//better than realloc } if(src.mPathPoints>0) { -- 2.11.4.GIT