Bug 959413, part 3 - Smart pointerize nsXPCConstructor. r=bholley

This commit is contained in:
Andrew McCreight 2014-01-16 08:49:25 -08:00
parent 9b90661651
commit eae2f4253b

View File

@ -1941,8 +1941,8 @@ private:
JSContext *cx, HandleObject obj, JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval); const CallArgs &args, bool *_retval);
private: private:
nsIJSCID* mClassID; nsRefPtr<nsIJSCID> mClassID;
nsIJSIID* mInterfaceID; nsRefPtr<nsIJSIID> mInterfaceID;
char* mInitializer; char* mInitializer;
}; };
@ -2041,9 +2041,9 @@ nsXPCConstructor::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
nsXPCConstructor::nsXPCConstructor(nsIJSCID* aClassID, nsXPCConstructor::nsXPCConstructor(nsIJSCID* aClassID,
nsIJSIID* aInterfaceID, nsIJSIID* aInterfaceID,
const char* aInitializer) const char* aInitializer)
: mClassID(aClassID),
mInterfaceID(aInterfaceID)
{ {
NS_IF_ADDREF(mClassID = aClassID);
NS_IF_ADDREF(mInterfaceID = aInterfaceID);
mInitializer = aInitializer ? mInitializer = aInitializer ?
(char*) nsMemory::Clone(aInitializer, strlen(aInitializer)+1) : (char*) nsMemory::Clone(aInitializer, strlen(aInitializer)+1) :
nullptr; nullptr;
@ -2051,8 +2051,6 @@ nsXPCConstructor::nsXPCConstructor(nsIJSCID* aClassID,
nsXPCConstructor::~nsXPCConstructor() nsXPCConstructor::~nsXPCConstructor()
{ {
NS_IF_RELEASE(mClassID);
NS_IF_RELEASE(mInterfaceID);
if (mInitializer) if (mInitializer)
nsMemory::Free(mInitializer); nsMemory::Free(mInitializer);
} }
@ -2061,7 +2059,8 @@ nsXPCConstructor::~nsXPCConstructor()
NS_IMETHODIMP NS_IMETHODIMP
nsXPCConstructor::GetClassID(nsIJSCID * *aClassID) nsXPCConstructor::GetClassID(nsIJSCID * *aClassID)
{ {
NS_IF_ADDREF(*aClassID = mClassID); nsRefPtr<nsIJSCID> rval = mClassID;
rval.forget(aClassID);
return NS_OK; return NS_OK;
} }
@ -2069,7 +2068,8 @@ nsXPCConstructor::GetClassID(nsIJSCID * *aClassID)
NS_IMETHODIMP NS_IMETHODIMP
nsXPCConstructor::GetInterfaceID(nsIJSIID * *aInterfaceID) nsXPCConstructor::GetInterfaceID(nsIJSIID * *aInterfaceID)
{ {
NS_IF_ADDREF(*aInterfaceID = mInterfaceID); nsRefPtr<nsIJSIID> rval = mInterfaceID;
rval.forget(aInterfaceID);
return NS_OK; return NS_OK;
} }