Hi,
why does the following cause a segfault?
[void collectData(inout PRUint32 count, [array, size_is(count)] inout string
valueData);]
NS_IMETHODIMP
myimpl::collectData(PRUint32 *count, char ***valueData)
{
char** outArray = (char**) nsMemory::Alloc(*count * 2 * sizeof(char*));
PRUint32 *newcount = 0;
char *entry = "foobar" + '\0';
for(PRUint32 i = 0; i < *count; i++)
{
int len = strlen(entry);
outArray[i] = (char*)nsMemory::Alloc(len * sizeof(char) + 1);
outArray[i] = entry;
*newcount = i;
}
*valueData = outArray;
*count = *newcount;
return NS_OK;
}
I've read about ADDREF, but don't know how to use it. - But it seems like
there's an issue with memory access in the above. It runs through, but
crashes right after.
And I've read about using the event-queue and callbacks for such
communication, but would prefer the above approach if possible.
Many thanks,
Thomas
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom