Visit Mozilla.org

JS strdup

From MDC

Duplicates a specified string within a specific JS executable script context.

[edit] Syntax

char * JS_strdup(JSContext *cx, const char *s);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
s const char * Pointer to an existing string to duplicate.

[edit] Description

JS_strdup duplicates a specified string, s, within a specified JSContext, cx. To duplicate the string, JS_strdup allocates space for the copy of the string using JS_malloc, then copies s to the newly allocated location. If the allocation fails, JS_strdup calls JS_ReportOutOfMemory(cx) and returns NULL. Otherwise, it returns a pointer to the duplicate string.

[edit] See Also

LXR ID Search for JS_strdup

JS_free