473,668 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
1 2090

"Dodo" <pr************ *********@hotma il.com> wrote in message news:bie1dr$834 50
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2153
by: Martin Stich | last post by:
hi, i want to redefine the global operator new for logging and stats purposes. is it a good idea to use malloc() as allocation function ? or should i call one of those weird crt functions....or ask the OS directly? oh and another question: which parts of my program will actually use my version of new ? only the ones that include the declaration (do i even need one or is a definition in a cpp file ok?). what about statically linked...
7
2437
by: Emanuel Ziegler | last post by:
Hello, I want to do some mathematics with functions. In my case the function classes are very complex, but this simple example has the same problems. To allow calculations that begin with a double, I have to define a global operator+ (or -*/) and special function classes. --- source begins here ---
20
4140
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
3
2027
by: CoolPint | last post by:
After upgrading to gcc 3.4.2 from gcc 3.2.3, I got compiler errors that I could not figure out. After reading other postings, I learned that my coding was not compliant to the standard in the first place and I did fix many of them, especially with the proper use of the keyword "typename". But I have one problem I have no idea how to fix. I created below a simpler coding which demonstrates my problem: The coding below used to compile...
14
3653
by: ambar.shome | last post by:
Hi, As you know there are few operators in C++ which cant be overloaded. They are: .., .*, ::, ?: , new , delete , sizeof , typeid , static_casr , dynamic_cast , const_cast , reinterpret_cast . Theremust be some reason for this restriction for each of the
1
9999
by: Alex Zhitlenok | last post by:
Hi, My question is how to resolve in C# ambiguous overloaded operators? Let say, I have two unrelated classes A and B, each one implements overloaded operator + with the first parameter of type A, and the second one of type B. Let say, these are not my classes and I know nothing about the implementation. As system doesn't know what code must be used for resolving the language construction a+b (where A a; and B b;), it returns "The call...
13
5027
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I can't figure out what are the alignment requirements so that the implementation, after calling my...
2
1592
by: SlimT88 | last post by:
I recently created a simple class for a homework assignment and ran into compilation errors concerning overloaded global functions. I've copied the relevant parts of my code below and the errors generated on two compilers Class Definition: class BDay { //Should Be Global Scope bool operator==( const BDay & , const BDay &); bool operator!=( const BDay & , const BDay &); friend ostream & operator<<( ostream &, const BDay...
8
6113
by: Rahul | last post by:
Please read the following code class Test{ public: void * operator new (size_t t) { return malloc(t); } void operator delete (void *p) { free(p); } };
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8577
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.