Skip to content
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

Standard conformant operator new and operator delete #21

Open
kibergus opened this issue Aug 21, 2012 · 0 comments
Open

Standard conformant operator new and operator delete #21

kibergus opened this issue Aug 21, 2012 · 0 comments

Comments

@kibergus
Copy link

Please make implementations of these operator standard conformant. Those variants of new, which are already present in wiring library must check return value of malloc and, in case of memory allocation error call std::terminate. The reason is that nobody checks return value of new because it always returns valid address. So if you return 0 the firmware would crash badly because of memory corruption.
If programmer wants to check for address returned by new, he must call nothrow version of new which should be provided by the library.
There is also placement new, which is a must have tool for writing containers, such as circular buffer.

You can find correct implementation of them in uClibc++
https://github.com/kibergus/StandardCplusplus

Some additional information, why terminating program from new is a good solution is here:
http://kibergus.su/en/node/92

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant