JavaScript-1.5 Reference

JS_NewString Function

Summary

Allocates a new JS string.

Syntax

JSString * JS_NewString(JSContext *cx, char *bytes,
    size_t length);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
byteschar *Pointer to the byte array containing the text for the JS string to create.
lengthsize_tNumber of characters in the text string.

Description

JS_NewString uses the memory starting at bytes and ending at bytes + length as storage for the JS string it returns. The char array, bytes, must be allocated on the heap using JS_malloc. This means that your application is permitting the JS engine to handle this memory region. Your application should not free or otherwise manipulate this region of memory.

Using JS_NewString is analogous to assigning char * variables in C, and can save needless copying of data. If successful, JS_NewString returns a pointer to the JS string. Otherwise 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_InternString | JS_InternUCString | JS_InternUCStringN | JS_NewArrayObject | JS_NewDouble | JS_NewFunction | JS_NewObject | JS_NewStringCopyN | JS_NewStringCopyZ | JS_NewUCString | JS_NewUCStringCopyN | JS_NewUCStringCopyZ | JS_ValueToString | JS_malloc ]

This page was generated by APIDOC