472,358 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

Need for user defined delete or built-in will work?

When we do this

Test *ptr=new Test[10];

then runtime memory manager will allocate 10*sizeof(Test) + X bytes(X
varying from implementation to implementation)

But instead if I call operator new explicitly like

Test *ptr = static_cast<Test *>(operator new[]( 10*sizeof(Test) ));

Now there's no extra X bytes allocated by me. So, will the built-in
delete[] will work properly? or do I need to supply my own operator
delete[]?

Dec 25 '06 #1
2 1258

"Money" <sp*********@gmail.comwrote in message
news:11*********************@i12g2000cwa.googlegro ups.com...
When we do this

Test *ptr=new Test[10];

then runtime memory manager will allocate 10*sizeof(Test) + X bytes(X
varying from implementation to implementation)
There's no guarantee that the new[] operator or 'operator new[]()'
will allocate more than the size requested. Only that *at least*
the requested size will be allocated.
>
But instead if I call operator new explicitly like

Test *ptr = static_cast<Test *>(operator new[]( 10*sizeof(Test) ));

Now there's no extra X bytes allocated by me.
See above.
So, will the built-in
delete[] will work properly? or do I need to supply my own operator
delete[]?
Normally the new[] operator will suffice.

What specifically are you trying to do?

-Mike
Dec 25 '06 #2

Money wrote:
When we do this

Test *ptr=new Test[10];

then runtime memory manager will allocate 10*sizeof(Test) + X bytes(X
varying from implementation to implementation)

But instead if I call operator new explicitly like

Test *ptr = static_cast<Test *>(operator new[]( 10*sizeof(Test) ));

Now there's no extra X bytes allocated by me. So, will the built-in
delete[] will work properly? or do I need to supply my own operator
delete[]?
it might work for intrinsic types or simple types with no
destructor.but for other types it certainly will not.I am using ms
vc++.net 7 and this dosent work fine on it.because for destructable
arrays the compiler generates extra storage for number of elements to
be destructed.

Dec 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: M | last post by:
How do you permanently remove a user from the MySQL database. Delete from MySQL.user where user="Unwanted User"; just seems to ignored. Thanks, Martin
4
by: Bruce A. Julseth | last post by:
My MySQL.user table (user, host, password) looks like the following: +---------+-----------+---------------------+ | user | host | password |...
15
by: Roy Smith | last post by:
I understand that "delete xp" deletes a scalar object and "delete xp" deletes an array of objects, but what I don't understand is why you need to tell the compiler which you're doing. When you...
2
by: TOI DAY | last post by:
Hi all, How can I delete the file on the server after the user download it? For example: I have file name "123.txt" on a server, I copy it to "ABC.txt", then allow uer download the...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
27
by: Randy | last post by:
Is there a way to override operators for user-defined types (e.g., typedefs) rather than class types? I'm trying to override the extractor operator for a user-defined enumeration type but...
0
by: Darrel | last post by:
I've been having problems trying to delete a file. I can upload and save the file no problem, but deleting it gives me two results: If I run the delete function from my app's unprotected (public)...
7
by: python | last post by:
after del list , when I use it again, prompt 'not defined'.how could i delete its element,but not itself? except list.remove(val) ,are there other ways to delete list 's elements? and , I...
1
by: robinsand | last post by:
I am a new C++ programmer. I am still having trouble with certain data types and constructors, among other things. I'm not sure if I've used "std::string" properly throughout this program. I need...
6
by: JLupear | last post by:
I have written a code (a translation of my first one) that is not working. I did a user defined function that is used on 'onsubmit'. It should total the value from the form selections and...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.