[x265] [PATCH 2 of 5] do not check for NULL prior to delete, do not reset pointers in destructors

Steve Borho steve at borho.org
Wed Sep 18 20:52:06 CEST 2013


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1379525032 18000
#      Wed Sep 18 12:23:52 2013 -0500
# Node ID 0b1216d453cfb3660fb62d4dfedb9613158974ed
# Parent  e34d5dec483e0870265e8b783387faa13ec2745c
do not check for NULL prior to delete, do not reset pointers in destructors

A lot of our classes have destroy() methods. In those we try to zero deleted
pointers since there is a chance for multiple destroy() calls. But in
destructors the pointer storage itself will be released when the function exits

diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/SEI.h
--- a/source/Lib/TLibCommon/SEI.h	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/SEI.h	Wed Sep 18 12:23:52 2013 -0500
@@ -198,14 +198,8 @@
 
     virtual ~SEIPictureTiming()
     {
-        if (m_numNalusInDuMinus1 != NULL)
-        {
-            delete m_numNalusInDuMinus1;
-        }
-        if (m_duCpbRemovalDelayMinus1  != NULL)
-        {
-            delete m_duCpbRemovalDelayMinus1;
-        }
+        delete m_numNalusInDuMinus1;
+        delete m_duCpbRemovalDelayMinus1;
     }
 
     UInt  m_picStruct;
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -178,10 +178,6 @@
     if (m_depth) { X265_FREE(m_depth); m_depth = NULL; }
     if (m_width) { X265_FREE(m_width); m_width = NULL; }
     if (m_height) { X265_FREE(m_height); m_height = NULL; }
-    if (m_skipFlag) { delete[] m_skipFlag; m_skipFlag = NULL; }
-    if (m_partSizes) { delete[] m_partSizes; m_partSizes = NULL; }
-    if (m_predModes) { delete[] m_predModes; m_predModes = NULL; }
-    if (m_cuTransquantBypass) { delete[] m_cuTransquantBypass; m_cuTransquantBypass = NULL; }
     if (m_cbf[0]) { X265_FREE(m_cbf[0]); m_cbf[0] = NULL; }
     if (m_cbf[1]) { X265_FREE(m_cbf[1]); m_cbf[1] = NULL; }
     if (m_cbf[2]) { X265_FREE(m_cbf[2]); m_cbf[2] = NULL; }
@@ -201,10 +197,14 @@
     if (m_iPCMSampleY) { X265_FREE(m_iPCMSampleY); m_iPCMSampleY = NULL; }
     if (m_iPCMSampleCb) { X265_FREE(m_iPCMSampleCb); m_iPCMSampleCb = NULL; }
     if (m_iPCMSampleCr) { X265_FREE(m_iPCMSampleCr); m_iPCMSampleCr = NULL; }
-    if (m_mvpIdx[0]) { delete[] m_mvpIdx[0]; m_mvpIdx[0] = NULL; }
-    if (m_mvpIdx[1]) { delete[] m_mvpIdx[1]; m_mvpIdx[1] = NULL; }
-    if (m_mvpNum[0]) { delete[] m_mvpNum[0]; m_mvpNum[0] = NULL; }
-    if (m_mvpNum[1]) { delete[] m_mvpNum[1]; m_mvpNum[1] = NULL; }
+    delete[] m_cuTransquantBypass; m_cuTransquantBypass = NULL;
+    delete[] m_mvpIdx[0]; m_mvpIdx[0] = NULL;
+    delete[] m_mvpIdx[1]; m_mvpIdx[1] = NULL;
+    delete[] m_mvpNum[0]; m_mvpNum[0] = NULL;
+    delete[] m_mvpNum[1]; m_mvpNum[1] = NULL;
+    delete[] m_skipFlag; m_skipFlag = NULL;
+    delete[] m_partSizes; m_partSizes = NULL;
+    delete[] m_predModes; m_predModes = NULL;
 
     m_cuMvField[0].destroy();
     m_cuMvField[1].destroy();
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -107,16 +107,10 @@
 {
     for (UInt dir = 0; dir < 2; dir++)
     {
-        if (m_blockingStrength)
-        {
-            delete [] m_blockingStrength[dir];
-            m_blockingStrength[dir] = NULL;
-        }
-        if (m_bEdgeFilter[dir])
-        {
-            delete [] m_bEdgeFilter[dir];
-            m_bEdgeFilter[dir] = NULL;
-        }
+        delete [] m_blockingStrength[dir];
+        m_blockingStrength[dir] = NULL;
+        delete [] m_bEdgeFilter[dir];
+        m_bEdgeFilter[dir] = NULL;
     }
 }
 
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComPicSym.cpp
--- a/source/Lib/TLibCommon/TComPicSym.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComPicSym.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -97,10 +97,7 @@
 
 void TComPicSym::destroy()
 {
-    if (m_slice)
-    {
-        delete m_slice;
-    }
+    delete m_slice;
     m_slice = NULL;
 
     for (int i = 0; i < m_numCUsInFrame; i++)
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComPrediction.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -81,10 +81,7 @@
 
     m_predTempYuv.destroy();
 
-    if (m_lumaRecBuffer)
-    {
-        delete [] m_lumaRecBuffer;
-    }
+    delete [] m_lumaRecBuffer;
 
     if (m_immedVals)
         X265_FREE(m_immedVals);
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -50,10 +50,7 @@
 {
     for (int i = 0; i < 3; i++)
     {
-        if (saoPart[i])
-        {
-            delete [] saoPart[i];
-        }
+        delete [] saoPart[i];
     }
 }
 
@@ -272,37 +269,18 @@
  */
 void TComSampleAdaptiveOffset::destroy()
 {
-    if (m_clipTableBase)
-    {
-        delete [] m_clipTableBase;
-        m_clipTableBase = NULL;
-    }
-    if (m_offsetBo)
-    {
-        delete [] m_offsetBo;
-        m_offsetBo = NULL;
-    }
-    if (m_lumaTableBo)
-    {
-        delete[] m_lumaTableBo;
-        m_lumaTableBo = NULL;
-    }
-
-    if (m_chromaClipTableBase)
-    {
-        delete [] m_chromaClipTableBase;
-        m_chromaClipTableBase = NULL;
-    }
-    if (m_chromaOffsetBo)
-    {
-        delete [] m_chromaOffsetBo;
-        m_chromaOffsetBo = NULL;
-    }
-    if (m_chromaTableBo)
-    {
-        delete[] m_chromaTableBo;
-        m_chromaTableBo = NULL;
-    }
+    delete [] m_clipTableBase;
+    m_clipTableBase = NULL;
+    delete [] m_offsetBo;
+    m_offsetBo = NULL;
+    delete[] m_lumaTableBo;
+    m_lumaTableBo = NULL;
+    delete [] m_chromaClipTableBase;
+    m_chromaClipTableBase = NULL;
+    delete [] m_chromaOffsetBo;
+    m_chromaOffsetBo = NULL;
+    delete[] m_chromaTableBo;
+    m_chromaTableBo = NULL;
 
     if (m_upBuff1)
     {
@@ -322,34 +300,22 @@
         delete [] m_upBufft;
         m_upBufft = NULL;
     }
-    if (m_tmpL1)
-    {
-        delete [] m_tmpL1;
-        m_tmpL1 = NULL;
-    }
-    if (m_tmpL2)
-    {
-        delete [] m_tmpL2;
-        m_tmpL2 = NULL;
-    }
-    if (m_tmpU1[0])
-    {
-        delete [] m_tmpU1[0];
-        delete [] m_tmpU1[1];
-        delete [] m_tmpU1[2];
-        m_tmpU1[0] = NULL;
-        m_tmpU1[1] = NULL;
-        m_tmpU1[2] = NULL;
-    }
-    if (m_tmpU2[0])
-    {
-        delete [] m_tmpU2[0];
-        delete [] m_tmpU2[1];
-        delete [] m_tmpU2[2];
-        m_tmpU2[0] = NULL;
-        m_tmpU2[1] = NULL;
-        m_tmpU2[2] = NULL;
-    }
+    delete [] m_tmpL1;
+    m_tmpL1 = NULL;
+    delete [] m_tmpL2;
+    m_tmpL2 = NULL;
+    delete [] m_tmpU1[0];
+    delete [] m_tmpU1[1];
+    delete [] m_tmpU1[2];
+    m_tmpU1[0] = NULL;
+    m_tmpU1[1] = NULL;
+    m_tmpU1[2] = NULL;
+    delete [] m_tmpU2[0];
+    delete [] m_tmpU2[1];
+    delete [] m_tmpU2[2];
+    m_tmpU2[0] = NULL;
+    m_tmpU2[1] = NULL;
+    m_tmpU2[2] = NULL;
 }
 
 /** allocate memory for SAO parameters
@@ -484,21 +450,12 @@
     saoParam->saoPart[0] = 0;
     saoParam->saoPart[1] = 0;
     saoParam->saoPart[2] = 0;
-    if (saoParam->saoLcuParam[0])
-    {
-        delete [] saoParam->saoLcuParam[0];
-        saoParam->saoLcuParam[0] = NULL;
-    }
-    if (saoParam->saoLcuParam[1])
-    {
-        delete [] saoParam->saoLcuParam[1];
-        saoParam->saoLcuParam[1] = NULL;
-    }
-    if (saoParam->saoLcuParam[2])
-    {
-        delete [] saoParam->saoLcuParam[2];
-        saoParam->saoLcuParam[2] = NULL;
-    }
+    delete [] saoParam->saoLcuParam[0];
+    saoParam->saoLcuParam[0] = NULL;
+    delete [] saoParam->saoLcuParam[1];
+    saoParam->saoLcuParam[1] = NULL;
+    delete [] saoParam->saoLcuParam[2];
+    saoParam->saoLcuParam[2] = NULL;
 }
 
 /** reset SAO parameters
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComSlice.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -107,7 +107,6 @@
 TComSlice::~TComSlice()
 {
     delete[] m_substreamSizes;
-    m_substreamSizes = NULL;
 }
 
 void TComSlice::initSlice()
@@ -957,9 +956,9 @@
 
 TComVPS::~TComVPS()
 {
-    if (m_hrdParameters    != NULL) delete[] m_hrdParameters;
-    if (m_hrdOpSetIdx      != NULL) delete[] m_hrdOpSetIdx;
-    if (m_cprmsPresentFlag != NULL) delete[] m_cprmsPresentFlag;
+    delete[] m_hrdParameters;
+    delete[] m_hrdOpSetIdx;
+    delete[] m_cprmsPresentFlag;
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -1337,10 +1336,7 @@
 
 void TComRPSList::destroy()
 {
-    if (m_referencePictureSets)
-    {
-        delete [] m_referencePictureSets;
-    }
+    delete [] m_referencePictureSets;
     m_numberOfReferencePictureSets = 0;
     m_referencePictureSets = NULL;
 }
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -87,14 +87,10 @@
     if (m_tmpCoeff)
     {
         X265_FREE(m_tmpCoeff);
-        m_tmpCoeff = NULL;
     }
 
     // delete bit estimation class
-    if (m_estBitsSbac)
-    {
-        delete m_estBitsSbac;
-    }
+    delete m_estBitsSbac;
     destroyScalingList();
 }
 
@@ -1658,9 +1654,9 @@
         {
             for (UInt qp = 0; qp < SCALING_LIST_REM_NUM; qp++)
             {
-                if (m_quantCoef[sizeId][listId][qp]) delete [] m_quantCoef[sizeId][listId][qp];
-                if (m_dequantCoef[sizeId][listId][qp]) delete [] m_dequantCoef[sizeId][listId][qp];
-                if (m_errScale[sizeId][listId][qp]) delete [] m_errScale[sizeId][listId][qp];
+                delete [] m_quantCoef[sizeId][listId][qp];
+                delete [] m_dequantCoef[sizeId][listId][qp];
+                delete [] m_errScale[sizeId][listId][qp];
             }
         }
     }
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -312,121 +312,66 @@
         }
     }
 
-    if (m_interCU_2Nx2N)
-    {
-        delete [] m_interCU_2Nx2N;
-        m_interCU_2Nx2N = NULL;
-    }
-    if (m_interCU_2NxN)
-    {
-        delete [] m_interCU_2NxN;
-        m_interCU_2NxN = NULL;
-    }
-    if (m_interCU_Nx2N)
-    {
-        delete [] m_interCU_Nx2N;
-        m_interCU_Nx2N = NULL;
-    }
-    if (m_intraInInterCU)
-    {
-        delete [] m_intraInInterCU;
-        m_intraInInterCU = NULL;
-    }
-    if (m_mergeCU)
-    {
-        delete [] m_mergeCU;
-        m_mergeCU = NULL;
-    }
-    if (m_bestMergeCU)
-    {
-        delete [] m_bestMergeCU;
-        m_bestMergeCU = NULL;
-    }
-    if (m_bestCU)
-    {
-        delete [] m_bestCU;
-        m_bestCU = NULL;
-    }
-    if (m_tempCU)
-    {
-        delete [] m_tempCU;
-        m_tempCU = NULL;
-    }
+    delete [] m_interCU_2Nx2N;
+    m_interCU_2Nx2N = NULL;
+    delete [] m_interCU_2NxN;
+    m_interCU_2NxN = NULL;
+    delete [] m_interCU_Nx2N;
+    m_interCU_Nx2N = NULL;
+    delete [] m_intraInInterCU;
+    m_intraInInterCU = NULL;
+    delete [] m_mergeCU;
+    m_mergeCU = NULL;
+    delete [] m_bestMergeCU;
+    m_bestMergeCU = NULL;
+    delete [] m_bestCU;
+    m_bestCU = NULL;
+    delete [] m_tempCU;
+    m_tempCU = NULL;
 
     for (int j = 0; j < 4; j++)
     {
-        if (m_interCU_NxN[j])
-        {
-            delete [] m_interCU_NxN[j];
-            m_interCU_NxN[j] = NULL;
-        }
+        delete [] m_interCU_NxN[j];
+        m_interCU_NxN[j] = NULL;
     }
 
-    if (m_bestPredYuv)
-    {
-        delete [] m_bestPredYuv;
-        m_bestPredYuv = NULL;
-    }
-    if (m_bestResiYuv)
-    {
-        delete [] m_bestResiYuv;
-        m_bestResiYuv = NULL;
-    }
-    if (m_bestRecoYuv)
-    {
-        delete [] m_bestRecoYuv;
-        m_bestRecoYuv = NULL;
-    }
+    delete [] m_bestPredYuv;
+    m_bestPredYuv = NULL;
+    delete [] m_bestResiYuv;
+    m_bestResiYuv = NULL;
+    delete [] m_bestRecoYuv;
+    m_bestRecoYuv = NULL;
+
     for (int j = 0; j < 4; j++)
     {
-        if (m_bestPredYuvNxN[j])
-        {
-            delete [] m_bestPredYuvNxN[j];
-            m_bestPredYuvNxN[j] = NULL;
-        }
+        delete [] m_bestPredYuvNxN[j];
+        m_bestPredYuvNxN[j] = NULL;
     }
 
-    if (m_bestMergeRecoYuv)
-    {
-        delete [] m_bestMergeRecoYuv;
-        m_bestMergeRecoYuv = NULL;
-    }
-    if (m_tmpPredYuv)
-    {
-        delete [] m_tmpPredYuv;
-        m_tmpPredYuv = NULL;
-    }
+    delete [] m_bestMergeRecoYuv;
+    m_bestMergeRecoYuv = NULL;
+    delete [] m_tmpPredYuv;
+    m_tmpPredYuv = NULL;
+
     for (int i = 0; i < MAX_PRED_TYPES; i++)
     {
-        if (m_modePredYuv[i])
-        {
-            delete [] m_modePredYuv[i];
-            m_modePredYuv[i] = NULL;
-        }
+        delete [] m_modePredYuv[i];
+        m_modePredYuv[i] = NULL;
     }
 
-    if (m_tmpResiYuv)
-    {
-        delete [] m_tmpResiYuv;
-        m_tmpResiYuv = NULL;
-    }
-    if (m_tmpRecoYuv)
-    {
-        delete [] m_tmpRecoYuv;
-        m_tmpRecoYuv = NULL;
-    }
-    if (m_origYuv)
-    {
-        delete [] m_origYuv;
-        m_origYuv = NULL;
-    }
+    delete [] m_tmpResiYuv;
+    m_tmpResiYuv = NULL;
+    delete [] m_tmpRecoYuv;
+    m_tmpRecoYuv = NULL;
+    delete [] m_origYuv;
+    m_origYuv = NULL;
 }
 
 /** \param    pcEncTop      pointer of encoder class
  */
 void TEncCu::init(TEncTop* top)
 {
-    m_cfg         = top;
+    m_cfg = top;
 }
 
 // ====================================================================================================================
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -393,100 +393,43 @@
     {
         for (int j = 0; j < MAX_NUM_SAO_TYPE; j++)
         {
-            if (m_count[i][j])
-            {
-                delete [] m_count[i][j];
-            }
-            if (m_offset[i][j])
-            {
-                delete [] m_offset[i][j];
-            }
-            if (m_offsetOrg[i][j])
-            {
-                delete [] m_offsetOrg[i][j];
-            }
+            delete [] m_count[i][j];
+            delete [] m_offset[i][j];
+            delete [] m_offsetOrg[i][j];
         }
 
-        if (m_rate[i])
-        {
-            delete [] m_rate[i];
-        }
-        if (m_dist[i])
-        {
-            delete [] m_dist[i];
-        }
-        if (m_cost[i])
-        {
-            delete [] m_cost[i];
-        }
-        if (m_count[i])
-        {
-            delete [] m_count[i];
-        }
-        if (m_offset[i])
-        {
-            delete [] m_offset[i];
-        }
-        if (m_offsetOrg[i])
-        {
-            delete [] m_offsetOrg[i];
-        }
+        delete [] m_rate[i];
+        delete [] m_dist[i];
+        delete [] m_cost[i];
+        delete [] m_count[i];
+        delete [] m_offset[i];
+        delete [] m_offsetOrg[i];
     }
 
-    if (m_distOrg)
-    {
-        delete [] m_distOrg;
-        m_distOrg = NULL;
-    }
-    if (m_costPartBest)
-    {
-        delete [] m_costPartBest;
-        m_costPartBest = NULL;
-    }
-    if (m_typePartBest)
-    {
-        delete [] m_typePartBest;
-        m_typePartBest = NULL;
-    }
-    if (m_rate)
-    {
-        delete [] m_rate;
-        m_rate = NULL;
-    }
-    if (m_dist)
-    {
-        delete [] m_dist;
-        m_dist = NULL;
-    }
-    if (m_cost)
-    {
-        delete [] m_cost;
-        m_cost = NULL;
-    }
-    if (m_count)
-    {
-        delete [] m_count;
-        m_count = NULL;
-    }
-    if (m_offset)
-    {
-        delete [] m_offset;
-        m_offset = NULL;
-    }
-    if (m_offsetOrg)
-    {
-        delete [] m_offsetOrg;
-        m_offsetOrg = NULL;
-    }
+    delete [] m_distOrg;
+    m_distOrg = NULL;
+    delete [] m_costPartBest;
+    m_costPartBest = NULL;
+    delete [] m_typePartBest;
+    m_typePartBest = NULL;
+    delete [] m_rate;
+    m_rate = NULL;
+    delete [] m_dist;
+    m_dist = NULL;
+    delete [] m_cost;
+    m_cost = NULL;
+    delete [] m_count;
+    m_count = NULL;
+    delete [] m_offset;
+    m_offset = NULL;
+    delete [] m_offsetOrg;
+    m_offsetOrg = NULL;
 
-    if (m_countPreDblk)
-    {
-        delete[] m_countPreDblk;
-        m_countPreDblk = NULL;
+    delete[] m_countPreDblk;
+    m_countPreDblk = NULL;
 
-        delete[] m_offsetOrgPreDblk;
-        m_offsetOrgPreDblk = NULL;
-    }
+    delete[] m_offsetOrgPreDblk;
+    m_offsetOrgPreDblk = NULL;
 
     int maxDepth = 4;
     for (int d = 0; d < maxDepth + 1; d++)
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -111,11 +111,7 @@
 
 TEncSearch::~TEncSearch()
 {
-    if (m_tempPel)
-    {
-        delete [] m_tempPel;
-        m_tempPel = NULL;
-    }
+    delete [] m_tempPel;
 
     if (m_cfg)
     {
diff -r e34d5dec483e -r 0b1216d453cf source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -134,11 +134,8 @@
         delete m_lookahead;
     }
 
-    if (m_dpb)
-        delete m_dpb;
-
-    if (m_rateControl)
-        delete m_rateControl;
+    delete m_dpb;
+    delete m_rateControl;
 
     // thread pool release should always happen last
     if (m_threadPool)
diff -r e34d5dec483e -r 0b1216d453cf source/common/wavefront.cpp
--- a/source/common/wavefront.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/common/wavefront.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -54,16 +54,8 @@
 
 WaveFront::~WaveFront()
 {
-    if (m_queuedBitmap)
-    {
-        delete[] m_queuedBitmap;
-        m_queuedBitmap = NULL;
-    }
-    if (m_enableBitmap)
-    {
-        delete[] m_enableBitmap;
-        m_enableBitmap = NULL;
-    }
+    delete[] m_queuedBitmap;
+    delete[] m_enableBitmap;
 }
 
 void WaveFront::clearEnabledRowMask()
diff -r e34d5dec483e -r 0b1216d453cf source/encoder/bitcost.cpp
--- a/source/encoder/bitcost.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/encoder/bitcost.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -96,10 +96,6 @@
         }
     }
 
-    if (s_bitsizes)
-    {
-        delete [] s_bitsizes;
-
-        s_bitsizes = 0;
-    }
+    delete [] s_bitsizes;
+    s_bitsizes = 0;
 }
diff -r e34d5dec483e -r 0b1216d453cf source/input/y4m.cpp
--- a/source/input/y4m.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/input/y4m.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -42,7 +42,7 @@
 Y4MInput::~Y4MInput()
 {
     ifs.close();
-    if (buf) delete[] buf;
+    delete[] buf;
 }
 
 void Y4MInput::parseHeader()
diff -r e34d5dec483e -r 0b1216d453cf source/input/yuv.cpp
--- a/source/input/yuv.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/input/yuv.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -40,7 +40,7 @@
 YUVInput::~YUVInput()
 {
     ifs.close();
-    if (buf) delete[] buf;
+    delete[] buf;
 }
 
 int YUVInput::guessFrameCount()
diff -r e34d5dec483e -r 0b1216d453cf source/output/y4m.cpp
--- a/source/output/y4m.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/output/y4m.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -44,7 +44,7 @@
 Y4MOutput::~Y4MOutput()
 {
     ofs.close();
-    if (buf) delete [] buf;
+    delete [] buf;
 }
 
 bool Y4MOutput::writePicture(const x265_picture_t& pic)
diff -r e34d5dec483e -r 0b1216d453cf source/output/yuv.cpp
--- a/source/output/yuv.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/output/yuv.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -40,7 +40,7 @@
 YUVOutput::~YUVOutput()
 {
     ofs.close();
-    if (buf) delete [] buf;
+    delete [] buf;
 }
 
 bool YUVOutput::writePicture(const x265_picture_t& pic)
diff -r e34d5dec483e -r 0b1216d453cf source/test/testpool.cpp
--- a/source/test/testpool.cpp	Wed Sep 18 11:29:47 2013 -0500
+++ b/source/test/testpool.cpp	Wed Sep 18 12:23:52 2013 -0500
@@ -81,11 +81,8 @@
         // this object's vtable to be destroyed
         JobProvider::flush();
 
-        if (this->cu)
-            delete[] this->cu;
-
-        if (this->row)
-            delete[] this->row;
+        delete[] this->cu;
+        delete[] this->row;
     }
 
     void initialize(int cols, int rows);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4038.diff
Type: text/x-patch
Size: 20992 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130918/70679e3c/attachment-0001.bin>


More information about the x265-devel mailing list