Subj : Re: JS_AddRoot & finalize problem To : netscape.public.mozilla.jseng From : anton muhin Date : Thu Jul 22 2004 10:02 pm Hello, Brendan! You answer with the lightning speed :)---thank you very much! Brendan Eich wrote: > The GC root protects the array, and I bet you have a reference from an > element in a (one of the jsvals in the |elements| vector in your code) > that refers to |obj|, directly or indirectly. Maybe, but I'm not sure: constructing is called from init class code that passes 0 as |nElements| and NULL as |elements|, so there seems to be no references, but I'm obviously missing something. > Instead of using a root *and* private data, you should simply store the > array object, |a|, be a slot in the object. You don't need to allocate > the private data slot, so remove JSCLASS_HAS_PRIVATE from your JSClass > flags. Instead, add JSCLASS_HAS_RESERVED_SLOTS(1), and use JS_Get- and > JS_SetReservedSlot with reserved slot index 0. Don't forget to use > JSVAL_TO_OBJECT on Get and OBJECT_TO_JSVAL on Set. Thank you very much---works like a charm! with the best regards, anton. .