Entry: JS_InternString (Function)
Summary: Creates a new, static JS string whose value is automatically shared by all string literals that are identical.
Syntax:
JSString * JS_InternString(JSContext *cx, const char *s);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
s const char * Pointer to the character array containing the text for the JS string to create.
Description:
JS_InternString creates a new JS string with a specified value, s, if it does not already exist. The char array, s, must be allocated on the heap. The JS string is an interned, Unicode version of s, meaning that independent C variables that define a matching string will, when translated to a JS string value using JS_InternString, share the same internal copy of the JS string, rather than define their own, separate copies in memory. Use this function to save space allocation on the heap.
If it creates or reuses an interned string, JS_InternString returns a pointer to the string. Otherwise, on error, it returns NULL.
See also:
|
|
|