Date
1 - 4 of 4
c++ application development #nrf52840
Narendar Malepu
Hi,
we are developing an application in c++, for dynamic memory allocation using new as operator overloading as below void *operator new(size_t size) {
void *p = malloc(size);
return p;
}
void operator delete(void *ptr)
{
free(ptr);
} but as per documentation it is mention that new and delete are not supported, complier is not showing any error or warning for my usage. Can you help regarding above new operator overloading whether to use it or not in my application. Thanks
|
|
Peter A. Bigot
Dynamic memory allocation is supported in Zephyr C++, though you have to enable a source for the memory. You should not have to define overloads for those operators.
tests/application_development/libcxx in current master is the most complete example of C++ use. PRs 18464, 18991, and 19002 may be helpful as well. Peter
|
|
Narendar Malepu
Hi, Is there source for memory allocation using new other than k_malloc ? Because in my application want to use memory alloation from free heap not from the heap memory pool.
On Thu, Sep 12, 2019 at 6:11 AM Peter A. Bigot <pab@...> wrote: Dynamic memory allocation is supported in Zephyr C++, though you have to enable a source for the memory. You should not have to define overloads for those operators.
|
|
Peter A. Bigot
Not until we get #19002 and then #18464 merged. Since I'm the one with concerns about those I'll work to get them in next week if that's possible. For now you could make progress by taking 18464 into your Zephyr tree; then you can use the malloc-based new/delete that comes free from combining libc++ and newlib.
Peter
|
|