On 05/11/15 16:22, Daniel Gutson wrote:
On Wed, Nov 4, 2015 at 3:20 AM, Jonathan Wakely<jwakely....@gmail.com>  wrote:
>On 4 November 2015 at 02:11, Daniel Gutson wrote:
>>Since this is a nothrow new, we thought that probably the system
>>might not be exceptions-friendly (such as certain embedded systems),
>>so we wanted to provide the new_handler the ability to do something else
>>other than trying to allocate memory and keep the function iterating.
>
>That could be done using an alternative overload of operator new
>instead of altering the semantics of the standard one (that could be
>provided as a GNU extension, for example).
>
>>In fact, our idea is that since the nothrow new can indeed return nullptr,
>>let the new_handler do something else and leave the no-memory-consequence
>>to the caller.
>>This new flag enables just that.
>
>
>The default configuration already allows the caller to deal with
>allocation failure from the nothrow version of new, by not installing
>a new-handler installed, and dealing with a null return value. How
>would I use this alternative configuration? Since the behaviour only
>changes when a new-handler is installed, presumably I'm meant to
>install some kind of new-handler that does something else ... but
>what? The patch should include documentation explaining when and how
>to use this option.
Real use cases: statistics and logging. It's a (one time) callback
reporting that something went wrong,
but not intended to fix things e.g. by attempting to free more memory.

For statistics and logging you may also use the --wrap option of GNU ld.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

Reply via email to