JavaScript-1.5 Reference

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);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
sconst 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

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_CompareStrings | JS_ConvertValue | JS_GetEmptyStringValue | JS_GetStringBytes | JS_GetStringChars | JS_GetStringLength | JS_InternUCString | JS_InternUCStringN | JS_NewArrayObject | JS_NewDouble | JS_NewFunction | JS_NewObject | JS_NewString | JS_NewStringCopyN | JS_NewStringCopyZ | JS_NewUCString | JS_NewUCStringCopyN | JS_NewUCStringCopyZ | JS_ValueToString ]

This page was generated by APIDOC