Subj : Help with rooting, JSStrings and JS_DefineFunction To : netscape.public.mozilla.jseng From : altan Date : Wed Dec 01 2004 10:49 am I have a question regarding interfacing C functions with JavaScript (SpinderMonkey RC3) and the proper use of rooting. I've searched high and low for an answer, but have come up with nothing on this specific subject. When interfacing a C function with JavaScript, JS_DefineFunction is used. Let's assume the following C function is eventually called constructInternal( JSContext *cx, JSObject **obj, uintN argc, jsval *argv, jsval *rval) { ... } If one (or more) of the parameters passed in the argv is a JSString and the C code will continue to reference this JSString after constructInternal returns, do I need to worry about this string being garbage collected? For example, might it be garbage collected if the script containing the string that caused constructInternal to be executed terminates or under any other conditions? In general, what are the rules for keeping pointers to arbitrary argv's after a C function returns? Must I use JS_AddRoot in all such cases? Thanks in advance for any help. .... Altan .