Just checking, any C++ version dependency here? /Hans On 09/24/2013 12:57 PM, Hans Nordeback wrote: > osaf/services/saf/amf/amfd/main.cc | 12 ++++++++++++ > osaf/services/saf/amf/amfnd/main.cc | 12 ++++++++++++ > 2 files changed, 24 insertions(+), 0 deletions(-) > > > Add c++ new_handler to enable using new instead of malloc/calloc. > > diff --git a/osaf/services/saf/amf/amfd/main.cc > b/osaf/services/saf/amf/amfd/main.cc > --- a/osaf/services/saf/amf/amfd/main.cc > +++ b/osaf/services/saf/amf/amfd/main.cc > @@ -38,6 +38,7 @@ > > ****************************************************************************** > */ > > +#include <new> > #include <poll.h> > > #include <daemon.h> > @@ -611,6 +612,13 @@ done: > return rc; > } > > +// c++ new handler will be called if new fails. > +static void new_handler() > +{ > + syslog(LOG_ERR, "new failed, calling abort"); > + abort(); > +} > + > > /***************************************************************************** > * This is the main infinite loop in which both the active and > * standby waiting for events to happen. When woken up > @@ -627,6 +635,10 @@ static void main_loop(void) > int polltmo = -1; > int term_fd; > > + // function to be called if new fails. The alternative of using > catch of std::bad_alloc > + // will unwind the stack and thus no call chain will be available. > + std::set_new_handler(new_handler); > + > mbx_fd = ncs_ipc_get_sel_obj(&cb->avd_mbx); > daemon_sigterm_install(&term_fd); > > diff --git a/osaf/services/saf/amf/amfnd/main.cc > b/osaf/services/saf/amf/amfnd/main.cc > --- a/osaf/services/saf/amf/amfnd/main.cc > +++ b/osaf/services/saf/amf/amfnd/main.cc > @@ -16,6 +16,7 @@ > * > */ > > +#include <new> > #include <poll.h> > #include <sched.h> > #include <stdlib.h> > @@ -147,10 +148,21 @@ static int __init_avnd(void) > return (NCSCC_RC_SUCCESS); > } > > +// c++ new handler will be called if new fails. > +static void new_handler() > +{ > + syslog(LOG_ERR, "new failed, calling abort"); > + abort(); > +} > + > int main(int argc, char *argv[]) > { > uint32_t error; > > + // function to be called if new fails. The alternative of using > catch of std::bad_alloc > + // will unwind the stack and thus no call chain will be available. > + std::set_new_handler(new_handler); > + > if (avnd_failed_state_file_exist()) { > syslog(LOG_ERR, "system is in repair pending state, reboot or " > "manual cleanup needed"); > >
------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel