overloaded global operator new/new[] and corresponding deletes question

Discussion in 'C++' started by Dodo, Aug 25, 2003.

  1. Dodo

    Dodo Guest

    I have overloaded the global new/delete operators with
    something like this (simplified):

    void *operator new(size_t size)
    {
    ...allocation code...
    }

    void operator delete(void * p)
    {
    ...allocation code...
    }

    void *operator new[](size_t size)
    {
    ...deallocation code...
    }

    void operator delete[](void * p)
    {
    ...dealocation code...
    }

    Now given these overloaded ops, I try following code:
    char *p = new char[100];
    ....
    delete [] p;

    What is the correct new/delete pair of allocators that will be used?
    My problem is that under VC6, SP5 I always get new(size_t)/delte(void *)
    as allocators/dealocators. Same code under VC7.1 (.NET 2003) and
    Intel C++ 7.1 links to new(size_t)/delete[](void *). At this point I am
    puzzled.
    Isn't the correct linkage new[](size_t)/delete[](void *) even for scalar
    types?

    Thanks!
     
    Dodo, Aug 25, 2003
    #1
    1. Advertising

  2. Dodo

    Ron Natalie Guest

    "Dodo" <prokopcho_O> wrote in message news:bie1dr$83450
    > Isn't the correct linkage new[](size_t)/delete[](void *) even for scalar
    > types?
    >

    That is right (you mean for non-class types). Scalar just means not array.
     
    Ron Natalie, Aug 26, 2003
    #2
    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. John Goche
    Replies:
    2
    Views:
    348
    Frederick Gotham
    Sep 4, 2006
  2. Afshin
    Replies:
    0
    Views:
    295
    Afshin
    Aug 12, 2011
  3. Afshin
    Replies:
    0
    Views:
    301
    Afshin
    Aug 12, 2011
  4. Alex Vinokur
    Replies:
    0
    Views:
    473
    Alex Vinokur
    Jun 14, 2012
  5. Alex Vinokur
    Replies:
    3
    Views:
    502
    Zoltan Juhasz
    Jun 15, 2012
Loading...

Share This Page