History

add error handling in memory allocation failed case

sijchen committed 10 years ago

Commit cc675f91 parent a26955e2 files · +21 −5Browse files

Showing the changes to codec/common/src/WelsThreadPool.cpp (1 of 2 files). Show all

Unified · Split

codec/common/src/WelsThreadPool.cpp+16−2
@@ -50,7 +50,19 @@ CWelsThreadPool::CWelsThreadPool (IWelsThreadPoolSink* pSink, int32_t iMaxThread · 49 unmodified lines
5050 m_cBusyThreads = new CWelsList<CWelsTaskThread>();
5151 m_iMaxThreadNum = 0;
5252
53− Init (iMaxThreadNum);
53+ if (NULL == m_cWaitedTasks || NULL == m_cIdleThreads || NULL == m_cBusyThreads) {
54+ delete m_cWaitedTasks;
55+ delete m_cIdleThreads;
56+ delete m_cBusyThreads;
57+ return;
58+ }
59+
60+ if (WELS_THREAD_ERROR_OK != Init (iMaxThreadNum)) {
61+ Uninit();
62+ delete m_cWaitedTasks;
63+ delete m_cIdleThreads;
64+ delete m_cBusyThreads;
65+ }
5466 }
5567
5668
@@ -175,7 +187,9 @@ WELS_THREAD_ERROR_CODE CWelsThreadPool::CreateIdleThread() { · 118 unmodified lines
175187 return WELS_THREAD_ERROR_GENERAL;
176188 }
177189
178− pThread->Start();
190+ if (WELS_THREAD_ERROR_OK != pThread->Start()) {
191+ return WELS_THREAD_ERROR_GENERAL;
192+ }
179193 AddThreadToIdleQueue (pThread);
180194
181195 return WELS_THREAD_ERROR_OK;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t