Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Can new operator be used as macro?

Reply
Thread Tools

Can new operator be used as macro?

 
 
JeanDean
Guest
Posts: n/a
 
      03-02-2007
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) {
..
..
..
}

 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      03-02-2007
JeanDean wrote:
> 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 :perator new(size, WORK_HEAD);
}

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

john
 
Reply With Quote
 
 
 
 
JeanDean
Guest
Posts: n/a
 
      03-02-2007
On Mar 2, 4:59 pm, John Harrison <(E-Mail Removed)> wrote:
> JeanDean wrote:
> > 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 :perator new(size, WORK_HEAD);
>
> }
>
> Look's OK to me, unless I'm misunderstanding you.
>
> john


Thanks a lot for the suggestion

 
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
I am buying all of the below Cisco equipment USED OR NEW. NOTE someline items say new or used, but I will buy them in both conditions. network buyer VOIP 0 12-23-2010 01:26 AM
What are the key differences between operator new and operator new[]? xmllmx C++ 6 02-03-2010 04:11 PM
Can Groovy be used in an applet and/or can it generate the Java bytecodes that then can be used in an applet? Casey Hawthorne Java 1 03-18-2009 12:56 AM
Is there a perl package, or data in a form easily used by a perlscript, that can be used to determine when to change to or from daylightsavings time? Ted Byers Perl Misc 23 11-15-2008 05:53 PM
Memory leak with pointer used without new operator mfactor C++ 1 07-12-2008 03:10 PM



Advertisments