By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Dodo" <pr*********************@hotmail.com> 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.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.