-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert operator new and delete to use CHIPMem.h #3260
Conversation
#### Problem Embedded device-side code should only use heap through CHIPMem.h. In particular it should not use the C++ new and delete operators for heap allocation without explicit placement using Platform::MemoryAlloc(). #### Summary of Changes - Added Platform::New<>() and Delete<>(). - Convert uses of operator new and delete. Fixes project-chip#3232 Remove explicit use of `new` from first-party embedded-device code
Size increase report for "esp32-example-build"
Full report output
|
Size increase report for "nrfconnect-example-build"
Full report output
|
* In a few cases it may be necessary to add explicit casts to arguments, notably | ||
* when passing integer constants to smaller integer parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incidentally, the only reason this is not also true of things like std::make_unique
is that gcc magically suppresses warnings from system headers — which also means that -Wconversion
doesn't fire on code like this:
#include <memory>
struct Fewbits { Fewbits(short x) : m(x){}; short m; };
std::unique_ptr<Fewbits> f(long long manybits) { return std::make_unique<Fewbits>(manybits); }
With #3274 I can run locally and confirm the Cirque failure is genuine. Moving to draft state until fixed. |
Problem
Embedded device-side code should only use heap through CHIPMem.h.
In particular it should not use the C++ new and delete operators for
heap allocation without explicit placement using Platform::MemoryAlloc().
Summary of Changes
Fixes #3232 Remove explicit use of
new
from first-party embedded-device code