Skip to content

Standard conformant operator new and operator delete #21

@kibergus

Description

@kibergus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions