Re: CoTaskMemAlloc/CoTaskMemFree on XPCOM?

Doug Turner <[email protected]> Fri, 06 Dec 2002 11:55:20 -0800
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Jo Ueyama wrote:
> Hi All,
>     Is there any CoTaskMemAlloc/CoTaskMemFree functions for XPCOM? I am
> porting some code from MSCOM to XPCOM.
>     If there is *not* any similar function for XPCOM, should I just go
> for gcc malloc/free functions?
>     Thanks a lot in advance!
> 
> Cheers,
> -Jo
> 

See nsIMemory.idl and NS_GetMemoryManager().  Stay away from malloc/free 
if you are going to to be passing memory around (and may get deleted by 
another part of the system).  Although, XPCOM implementation of 
nsIMemory does use malloc/free under the hood, other parts of the system 
may not.

Regards,
--
Doug Turner
[email protected]