Subj : how to make C functions return array to js? To : netscape.public.mozilla.jseng From : Oyku Gencay Date : Wed Mar 17 2004 05:02 pm Hi folks, How can I return an array to javascript from a C function? I have a native C function which returns an array. When I run this I get a segfault. Is there any conceptual thing I'm missing? Thanks in advance Oyku. I want js to interpret and get an array object var x = Array(); x = TestingArraysAsReturn; The function code is; static JSBool TestingArraysAsReturn(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { JSObject *js_array ; js_array = JS_NewArrayObject(cx,0,NULL); for (i = 1 ; i <= 5 ; ++i) { jsval *js; js = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "testing")); JS_SetElement(cx,js_array,i,js); } *rval = OBJECT_TO_JSVAL(js_array); return JS_TRUE; } .