scopedAllocCString

abstract fun scopedAllocCString(jsString: JsString, returnWithLength: Boolean): JsAny(source)

Uses alloc() to allocate enough memory for the byte-length of the given JS string, plus 1 (for a NUL terminator), copies the given JS string to that memory using jstrcpy(), NUL-terminates it, and returns the pointer to that C-string. Ownership of the pointer is transfered to the caller, who must eventually pass the pointer to dealloc() to free it.

If passed a truthy 2nd argument then its return semantics change: it returns ptr,n, where ptr is the C-string's pointer and n is its cstrlen().