new operator implementation

  • Thread starter Peter Koch Larsen
  • Start date
P

Peter Koch Larsen

Ruslan Vorobey said:
Hi All.

Does anybody saw any C++ new operator implementations?
I need just to know does it use malloc?

It might, but there is now requirement for that.
Especially I interesting about standard C++ libs implementation under AIX
5.1L.
You must check that yourself. Read the documentation.
Thank you in advance.

Ruslan
I have no idea why this implementation detail is important to you. If
anything you could create your own new and delete operators implemented via
malloc and free if this is important to you.

/Peter
 
R

Ruslan Vorobey

Hi All.

Does anybody saw any C++ new operator implementations?
I need just to know does it use malloc?

Especially I interesting about standard C++ libs implementation under AIX
5.1L.

Thank you in advance.

Ruslan
 
J

JKop

Ruslan Vorobey posted:
Hi All.

Does anybody saw any C++ new operator implementations?
I need just to know does it use malloc?

Especially I interesting about standard C++ libs implementation under AIX
5.1L.

Thank you in advance.

Ruslan


For instance, on a Win32 system, a call to new triggers a call to the
Win32API function HeapAlloc.

-JKop
 
R

Ruslan Vorobey

I have a accidental crashes inside the new operator in program and know
about the ability to reload malloc on AIX
to introduce custom one. It is impossible to reload new everywhere because
program too large and complex.

The stack says about some malloc inside new so I hope to see it there.
 
J

Jukka Puurunen

Ruslan Vorobey said:
I have a accidental crashes inside the new operator in program and know
about the ability to reload malloc on AIX
to introduce custom one. It is impossible to reload new everywhere because
program too large and complex.

1. It is not very likely that malloc causes your crashes. More likely an
error somewhere else causes it.

2. How would you reload ( do you mead re-define? ) malloc? Why not overload
the
global "::eek:perator new "-function?

My suggestion is that you try to find the circumstances of the crashes more
accurately and that
way locate the real reason for the crashes.

Could you provide us with a backtrace of the core dump? That might help to
locate the problem.
Of course it's not so usefull without source codes...
 
P

Prateek R Karandikar

Ruslan Vorobey said:
Hi All.

Does anybody saw any C++ new operator implementations?
I need just to know does it use malloc?

The Standard does not require any particular implementation.
Therefore, malloc may or may not be used. Here is a *possible*
implementation (taken from TC++PL):

void *operator new(size_t size)
{
for(;;)
{
if(void *p=malloc(size)) return p;
if(_new_handler==0) throw bad_alloc();
_new_handler();
}
}

I repeat that the Standard does not require such an implementation to
be used, this is just a possible implementation. Also, _new_handler
isn't a standard name, here it is assumed _new_handler is the new
handler registered using set_new_handler. The name _new_handler is
used purely for illustration.
Especially I interesting about standard C++ libs implementation under AIX
5.1L.

Thank you in advance.
Welcome.

Ruslan

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L. Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 

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
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top