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

D

Dodo

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!
 
R

Ron Natalie

Dodo said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,814
Members
47,359
Latest member
Claim Bitcoin Earnings. $

Latest Threads

Top