Can new operator be used as macro?

J

JeanDean

For some debugging purpose I want to use overloaded new instead of
existing MyAlloc() in a huge code base.
But below macro doesnt work.
Is there any way to pass "size" to overloaded new ?


#define MyAlloc(size) new(size, WORK_HEAD )

overloaded new code is :
void* operator new(size_t sz, int headType) {
..
..
..
}
 
J

John Harrison

JeanDean said:
For some debugging purpose I want to use overloaded new instead of
existing MyAlloc() in a huge code base.
But below macro doesnt work.
Is there any way to pass "size" to overloaded new ?


#define MyAlloc(size) new(size, WORK_HEAD )

overloaded new code is :
void* operator new(size_t sz, int headType) {
.
.
.
}

Use operator new (which is a different thing from the new operator), but
why use a macro?

inline void* MyAlloc(size_t size)
{
return ::eek:perator new(size, WORK_HEAD);
}

Look's OK to me, unless I'm misunderstanding you.

john
 
J

JeanDean

Use operator new (which is a different thing from the new operator), but
why use a macro?

inline void* MyAlloc(size_t size)
{
return ::eek:perator new(size, WORK_HEAD);

}

Look's OK to me, unless I'm misunderstanding you.

john

Thanks a lot for the suggestion
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top