mirror of https://github.com/ARMmbed/mbed-os.git
Cast void pointer before deallocating with delete[]
The stack memory is a `void*` which creates a warning when using the `delete[]` operator because it is unable to call the destructor of of an unknown object type.pull/11696/head
parent
6176f066f4
commit
639ee4b3b4
|
@ -113,7 +113,8 @@ osStatus Thread::start(mbed::Callback<void()> task)
|
||||||
_tid = osThreadNew(Thread::_thunk, this, &_attr);
|
_tid = osThreadNew(Thread::_thunk, this, &_attr);
|
||||||
if (_tid == nullptr) {
|
if (_tid == nullptr) {
|
||||||
if (_dynamic_stack) {
|
if (_dynamic_stack) {
|
||||||
delete[] _attr.stack_mem;
|
// Cast before deallocation as delete[] does not accept void*
|
||||||
|
delete[] static_cast<uint32_t *>(_attr.stack_mem);
|
||||||
_attr.stack_mem = nullptr;
|
_attr.stack_mem = nullptr;
|
||||||
}
|
}
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
@ -417,7 +418,8 @@ Thread::~Thread()
|
||||||
// terminate is thread safe
|
// terminate is thread safe
|
||||||
terminate();
|
terminate();
|
||||||
if (_dynamic_stack) {
|
if (_dynamic_stack) {
|
||||||
delete[] _attr.stack_mem;
|
// Cast before deallocation as delete[] does not accept void*
|
||||||
|
delete[] static_cast<uint32_t *>(_attr.stack_mem);
|
||||||
_attr.stack_mem = nullptr;
|
_attr.stack_mem = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue