Hi,
I need to return an nsVariant object in XPCOM. I have been trying to do
that as follows.
NS_IMETHODIMP nsSimpleImpl::GetVarTest(nsIVariant * *aVarTest)
{
nsVariant *outVar = new nsVariant();
// Assign all the necessary fields in the object pointed by 'outVar'
*aVarTest = outVar;
return NS_OK;
}
However, XPConnect gives a Segmentation fault when it tries to deallocate
the memory assigned for outVar. I know I will have to use nsMemory::Alloc to
create an nsVariant object and then return that pointer.
In that case, if I do as following, how can initialize the nsVariant object?
nsVariant *outVar = (nsVariant *)nsMemory::Alloc(sizeof(nsVariant));
Without initailizing outVar object properly, all the assignments of the
fields in nsVariant are not working. In fact, if I try to call a function
like 'SetAsWStringWithSize' on outVar, it is giving a segmentation fault.
Thanks in advance.
Regards,
Anil
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom