Entry: JS_AddNamedRoot (Function)
Summary: Adds a garbage collection hash table entry for a named JS item to protect it from garbage collection.
Syntax:
JSBool JS_AddNamedRoot(JSContext *cx, void *rp,
const char *name);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
rp void * Pointer to the item to protect.
name char * Name of the item to protect
Description:
JS_AddNamedRoot protects the GC thing pointed at by a specified pointer, *rp, from garbage collection. rp is a pointer to a pointer to a JS double, string, or object. An entry for rp is added to the garbage collector's table for the JSRuntime of the specified JSContext, cx.
If the GC thing pointed to by *rp is an object, then any GC things reachable from it's properties are automatically protected from garbage collection, too.
The name parameter is stored in the JSRuntime's root table entry along with rp. The name string's lifetime must be at least as long as the JSRuntime's. Typically name is a static string constant, identifying the source location of the call to JS_AddNamedRoot, for debugging purposes. JS_DumpNamedRoots can be used to access this information from a debugger.
See also:
|
|
|