Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > overloaded global operator new/new[] and corresponding deletes question

Reply
Thread Tools

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

 
 
Dodo
Guest
Posts: n/a
 
      08-25-2003
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!

 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      08-26-2003

"Dodo" <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overloaded global delete is used instead of orignal global delete[] Alex Vinokur C++ 3 06-15-2012 05:12 PM
Different behavior overloaded global and local operator delete Alex Vinokur C++ 0 06-14-2012 05:28 AM
Problem in calling an overloaded operator= from inside anotheroverloaded operator= in C++ Afshin C++ 0 08-12-2011 12:19 PM
Problem in calling an overloaded operator= from inside anotheroverloaded operator Afshin C++ 0 08-12-2011 12:01 PM
"overloaded cast operator" and "operator const" John Goche C++ 2 09-04-2006 02:48 PM



Advertisments