overload operator new with a spcialized memory manager instance

Discussion in 'C++' started by Maximus, Aug 27, 2008.

  1. Maximus

    Maximus Guest

    I am trying to find a way to overload operator new of a class to use a
    specialzied memory manager. In my design multiple memory managers exist. I
    need to pass the instance of a memory manager into operator new. In ANSI C,
    it is quite simple, like this:

    type_t* ansi_c_init(MemoryManager* m)
    {
    type_t* a = (type_t*)->alloc_bytes(sizeof(type_t));
    a->memory_manager = m;
    }


    According to my read, the new() overload is actually a static method and can
    not call any members. So my question is, it is a backward in C++? Is it even
    possible to customize memory allocation with a specialized memory manager?
     
    Maximus, Aug 27, 2008
    #1
    1. Advertisements

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. Jakob Bieling

    Q: Overload operator new/delete

    Jakob Bieling, Aug 8, 2003, in forum: C++
    Replies:
    0
    Views:
    446
    Jakob Bieling
    Aug 8, 2003
  2. Piotre Ugrumov
    Replies:
    3
    Views:
    478
    Nick Hounsome
    Jan 25, 2004
  3. Shark
    Replies:
    2
    Views:
    682
    Alf P. Steinbach
    Jan 13, 2006
  4. Replies:
    5
    Views:
    623
    toton
    Sep 28, 2006
  5. Ying-Chieh Liao

    function overload (not operator overload)

    Ying-Chieh Liao, Oct 11, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    353
    Sherm Pendley
    Oct 11, 2004
Loading...

Share This Page