new operator implementation

Discussion in 'C++' started by Peter Koch Larsen, Jun 3, 2004.

  1. "Ruslan Vorobey" <> skrev i en meddelelse
    news:40bf2efb$...
    > Hi All.
    >
    > Does anybody saw any C++ new operator implementations?
    > I need just to know does it use malloc?


    It might, but there is now requirement for that.
    >
    > Especially I interesting about standard C++ libs implementation under AIX
    > 5.1L.

    You must check that yourself. Read the documentation.
    >
    > Thank you in advance.
    >
    > Ruslan
    >
    >

    I have no idea why this implementation detail is important to you. If
    anything you could create your own new and delete operators implemented via
    malloc and free if this is important to you.

    /Peter
     
    Peter Koch Larsen, Jun 3, 2004
    #1
    1. Advertising

  2. Hi All.

    Does anybody saw any C++ new operator implementations?
    I need just to know does it use malloc?

    Especially I interesting about standard C++ libs implementation under AIX
    5.1L.

    Thank you in advance.

    Ruslan
     
    Ruslan Vorobey, Jun 3, 2004
    #2
    1. Advertising

  3. Peter Koch Larsen

    JKop Guest

    Ruslan Vorobey posted:

    > Hi All.
    >
    > Does anybody saw any C++ new operator implementations?
    > I need just to know does it use malloc?
    >
    > Especially I interesting about standard C++ libs implementation under AIX
    > 5.1L.
    >
    > Thank you in advance.
    >
    > Ruslan



    For instance, on a Win32 system, a call to new triggers a call to the
    Win32API function HeapAlloc.

    -JKop
     
    JKop, Jun 3, 2004
    #3
  4. I have a accidental crashes inside the new operator in program and know
    about the ability to reload malloc on AIX
    to introduce custom one. It is impossible to reload new everywhere because
    program too large and complex.

    The stack says about some malloc inside new so I hope to see it there.


    "Peter Koch Larsen" <> wrote in message
    news:afGvc.7091$...
    >
    > "Ruslan Vorobey" <> skrev i en meddelelse
    > news:40bf2efb$...
    > > Hi All.
    > >
    > > Does anybody saw any C++ new operator implementations?
    > > I need just to know does it use malloc?

    >
    > It might, but there is now requirement for that.
    > >
    > > Especially I interesting about standard C++ libs implementation under

    AIX
    > > 5.1L.

    > You must check that yourself. Read the documentation.
    > >
    > > Thank you in advance.
    > >
    > > Ruslan
    > >
    > >

    > I have no idea why this implementation detail is important to you. If
    > anything you could create your own new and delete operators implemented

    via
    > malloc and free if this is important to you.
    >
    > /Peter
    >
    >
     
    Ruslan Vorobey, Jun 3, 2004
    #4
  5. "Ruslan Vorobey" <> kirjoitti viestissä
    news:40bf5495$...
    > I have a accidental crashes inside the new operator in program and know
    > about the ability to reload malloc on AIX
    > to introduce custom one. It is impossible to reload new everywhere because
    > program too large and complex.
    >


    1. It is not very likely that malloc causes your crashes. More likely an
    error somewhere else causes it.

    2. How would you reload ( do you mead re-define? ) malloc? Why not overload
    the
    global "::eek:perator new "-function?

    My suggestion is that you try to find the circumstances of the crashes more
    accurately and that
    way locate the real reason for the crashes.

    Could you provide us with a backtrace of the core dump? That might help to
    locate the problem.
    Of course it's not so usefull without source codes...
     
    Jukka Puurunen, Jun 3, 2004
    #5
  6. "Ruslan Vorobey" <> wrote in message news:<40bf2efb$>...
    > Hi All.
    >
    > Does anybody saw any C++ new operator implementations?
    > I need just to know does it use malloc?


    The Standard does not require any particular implementation.
    Therefore, malloc may or may not be used. Here is a *possible*
    implementation (taken from TC++PL):

    void *operator new(size_t size)
    {
    for(;;)
    {
    if(void *p=malloc(size)) return p;
    if(_new_handler==0) throw bad_alloc();
    _new_handler();
    }
    }

    I repeat that the Standard does not require such an implementation to
    be used, this is just a possible implementation. Also, _new_handler
    isn't a standard name, here it is assumed _new_handler is the new
    handler registered using set_new_handler. The name _new_handler is
    used purely for illustration.

    > Especially I interesting about standard C++ libs implementation under AIX
    > 5.1L.
    >
    > Thank you in advance.


    Welcome.

    > Ruslan


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    To iterate is human, to recurse divine.
    -L. Peter Deutsch
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
    Prateek R Karandikar, Jun 4, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    335
    Neil Cerutti
    Dec 22, 2005
  2. C++Liliput
    Replies:
    3
    Views:
    843
    korben dallas
    Sep 24, 2008
  3. xmllmx
    Replies:
    6
    Views:
    418
    xmllmx
    Feb 3, 2010
  4. Michael Tsang
    Replies:
    32
    Views:
    1,125
    Richard Bos
    Mar 1, 2010
  5. Replies:
    2
    Views:
    470
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page