shithub: openh264

Download patch

ref: e07ee9c09694f179b872701e505a05d407709bd2
parent: 74955c877fabef965a7d902b528fa8fff3ca6851
author: sijchen <sijchen@cisco.com>
date: Wed Feb 17 05:06:05 EST 2016

use WELS_DELETE_OP for deleting

--- a/codec/common/src/WelsThreadPool.cpp
+++ b/codec/common/src/WelsThreadPool.cpp
@@ -38,6 +38,7 @@
  *************************************************************************************
  */
 #include "typedefs.h"
+#include "memory_align.h"
 #include "WelsThreadPool.h"
 
 namespace WelsCommon {
@@ -51,15 +52,10 @@
   m_iMaxThreadNum = 0;
 
   if (NULL == m_cWaitedTasks || NULL == m_cIdleThreads || NULL == m_cBusyThreads) {
-    delete m_cWaitedTasks;
-    m_cWaitedTasks = NULL;
+    WELS_DELETE_OP(m_cWaitedTasks);
+    WELS_DELETE_OP(m_cIdleThreads);
+    WELS_DELETE_OP(m_cBusyThreads);
 
-    delete m_cIdleThreads;
-    m_cIdleThreads = NULL;
-
-    delete m_cBusyThreads;
-    m_cBusyThreads = NULL;
-
     return;
   }
 
@@ -66,14 +62,9 @@
   if (WELS_THREAD_ERROR_OK != Init (iMaxThreadNum)) {
     Uninit();
 
-    delete m_cWaitedTasks;
-    m_cWaitedTasks = NULL;
-
-    delete m_cIdleThreads;
-    m_cIdleThreads = NULL;
-
-    delete m_cBusyThreads;
-    m_cBusyThreads = NULL;
+    WELS_DELETE_OP(m_cWaitedTasks);
+    WELS_DELETE_OP(m_cIdleThreads);
+    WELS_DELETE_OP(m_cBusyThreads);
   }
 }
 
@@ -81,14 +72,9 @@
 CWelsThreadPool::~CWelsThreadPool() {
   Uninit();
 
-  delete m_cWaitedTasks;
-  m_cWaitedTasks = NULL;
-
-  delete m_cIdleThreads;
-  m_cIdleThreads = NULL;
-
-  delete m_cBusyThreads;
-  m_cBusyThreads = NULL;
+  WELS_DELETE_OP(m_cWaitedTasks);
+  WELS_DELETE_OP(m_cIdleThreads);
+  WELS_DELETE_OP(m_cBusyThreads);
 }
 
 WELS_THREAD_ERROR_CODE CWelsThreadPool::OnTaskStart (CWelsTaskThread* pThread, IWelsTask* pTask) {
@@ -214,7 +200,7 @@
 
 void  CWelsThreadPool::DestroyThread (CWelsTaskThread* pThread) {
   pThread->Kill();
-  delete pThread;
+  WELS_DELETE_OP(pThread);
 
   return;
 }
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2285,8 +2285,7 @@
     if ((*ppCtx)->pMemAlign != NULL) {
       WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO, "FreeMemorySvc(), verify memory usage (%d bytes) after free..",
                (*ppCtx)->pMemAlign->WelsGetMemoryUsage());
-      delete (*ppCtx)->pMemAlign;
-      (*ppCtx)->pMemAlign = NULL;
+      WELS_DELETE_OP((*ppCtx)->pMemAlign);
     }
 
     free (*ppCtx);
@@ -2474,8 +2473,7 @@
 
   if ((*ppCtx)->pVpp) {
     (*ppCtx)->pVpp->FreeSpatialPictures (*ppCtx);
-    delete (*ppCtx)->pVpp;
-    (*ppCtx)->pVpp = NULL;
+    WELS_DELETE_OP((*ppCtx)->pVpp);
   }
   FreeMemorySvc (ppCtx);
   *ppCtx = NULL;
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -413,8 +413,7 @@
   memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));
 
   if ((*ppCtx)->pTaskManage != NULL) {
-    delete (*ppCtx)->pTaskManage;
-    (*ppCtx)->pTaskManage = NULL;
+    WELS_DELETE_OP((*ppCtx)->pTaskManage);
   }
 
 #ifdef MT_DEBUG
--- a/codec/encoder/core/src/wels_task_management.cpp
+++ b/codec/encoder/core/src/wels_task_management.cpp
@@ -67,8 +67,7 @@
 
   if ( ENC_RETURN_SUCCESS != pTaskManage->Init (pCtx) ) {
     pTaskManage->Uninit();
-    delete pTaskManage;
-    pTaskManage = NULL;
+    WELS_DELETE_OP(pTaskManage);
   }
   return pTaskManage;
 }
@@ -117,8 +116,8 @@
   WELS_DELETE_OP (m_pThreadPool);
 
   for (int32_t iDid = 0; iDid < MAX_DEPENDENCY_LAYER; iDid++) {
-    delete m_cEncodingTaskList[iDid];
-    delete m_cPreEncodingTaskList[iDid];
+    WELS_DELETE_OP(m_cEncodingTaskList[iDid]);
+    WELS_DELETE_OP(m_cPreEncodingTaskList[iDid]);
   }
   WelsEventClose (&m_hTaskEvent);
 }