[webkit-dev] Fwd: How to OverLoad the new operator in webkit ?

praveen munukutla munukutlapraveen at gmail.com
Mon Dec 12 00:09:34 PST 2011


FYI

---------- Forwarded message ----------
From: praveen munukutla <munukutlapraveen at gmail.com>
Date: Mon, Dec 12, 2011 at 11:12 AM
Subject: [webkit-dev] How to OverLoad the new operator in webkit ?
To: zoltan at webkit.org


Hello Mr.Zoltan,

Thanks for the response.We are using the webkit revision of 72805.So we are
bound to use the Class version of FastAllocBase/Noncopyable .

I have to implement the "placement new" for memory leaks.I have written the
void* new(size_t,const char*,int) definition in the FastAllocBase.h ->
NonCopyable -> page.For testing purpose im trying to call the placement new
defined in the FastAllocBase from page. as


int * p = new(__FILE__,__LINE__) int;

which eventually should pick the void* new(size_t,const char*,int) but it
not happening .I am getting linker errors as void* new(size_t,const
char*,int) is undefined.

any idea how to solve this ?

Thanks ,
Praveen

Message: 19
Date: Fri, 9 Dec 2011 16:48:15 +0530
From: praveen munukutla <munukutlapraveen at gmail.com>
To: webkit-dev at lists.webkit.org
Subject: [webkit-dev] How to OverLoad the new operator in webkit ?
Message-ID:
       <CADhZ4C7HsHVNmkpnwJ2n8VfkYwkD2RGDeq2QhywLQtr8fxV6bw at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi all,

How to OverLoad the new operator in webkit ?

i have written an overloaded new operator void* operator new(size_t,int) in
the FastAllocBase.h

Fastallocbase is being inherited by Noncopyable  and the Noncopyable is
being inherited by class Page : public Noncopyable .

now im calling  int* p = new(1)int; in Page constructor. Page.cpp and
FastAllocBase.h are complied but there is a problem in linking.I am getting
a "undefined reference to operator new(unsigned int,int)" while linking
time.

Can anyone throw some light on this ?


Thanks in advance.
~Praveen Munukutla.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
http://lists.webkit.org/pipermail/webkit-dev/attachments/20111209/81f96b98/attachment-0001.html
>

------------------------------

Message: 20
Date: Fri, 09 Dec 2011 12:33:24 +0200
From: "Zoltan Horvath" <zoltan at webkit.org>
To: webkit-dev at lists.webkit.org
Subject: Re: [webkit-dev] How to OverLoad the new operator in webkit ?
Message-ID: <op.v57wxyhe2lq07i at csk.inf.u-szeged.hu>
Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes

Hi,

Noncopyable/FastAllocBase class doesn't exist anymore in WebKit, we turned
them into macro implementations:

http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/FastAllocBase.h
http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/Noncopyable.h

For primitive/POD types, you have to use FastNew to allocate and
FastDelete to deallocate memory, please check it in FastAllocBase.h.

Btw,  new(1)int; ? Do you mean new int[1]?

Regards,

Zoltan Horvath



-- 
~Praveen Munukutla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111212/44c3e9f5/attachment.html>


More information about the webkit-dev mailing list