Subj : Re: JS_ValueToString and STRING_TO_JSVAL To : netscape.public.mozilla.jseng From : Weiyang Zhou Date : Fri Aug 12 2005 01:13 am If I have the following code, do I have to add str to root too? jsval argv[1]; jsval rval; JSString* str = JS_NewString(context, "arg from C", 10); argv[0] = STRING_TO_JSVAL(str); JS_CallFunctionName(context, object, "myfunc", 1, argv, &rval); "Brendan Eich" wrote in message news:42FC29D9.8000408@meer.net... > Weiyang Zhou wrote: > >> What's the purpose of converting argv[i] to str, the assign str back to >> argv[i]? In the end, argv[i] remain the same. > > > Not if !JSVAL_IS_STRING(argv[i]) beforehand. > > See http://www.mozilla.org/js/spidermonkey/gctips.html for why this is > done in native methods such as Load. > > /be .