Search completed in 1.08 seconds.
JS_malloc
allocate and free memory that is not managed by the garbage collector. syntax void * js_malloc(jscontext *cx, size_t nbytes); void *
js_realloc(jscontext *cx, void *p, size_t oldbytes, size_t newbytes); char * js_strdup(jscontext *cx, const char *s); void js_free(jscontext *cx, void *p); name type description cx jscontext * pointer to a js context. if allocation fails, an error is reported in this context. p void * (
js_realloc and js_free only) pointer to a previously allocated region of memory to resize or deallocate. nbytes size_t (js_malloc and
js_realloc only) amount of space, in bytes, to allocate. s const char * (js_strdup only) pointer to a null-terminated string. s must not be null. description js_malloc ...
...c and
js_realloc only) amount of space, in bytes, to allocate. s const char * (js_strdup only) pointer to a null-terminated string. s must not be null. description js_malloc allocates a region of memory nbytes in size. on success, js_malloc returns a pointer to the beginning of the region. as with the standard c function malloc, memory allocated by js_malloc is uninitialized.
js_realloc tries to change the allocation size of the region of memory at p to nbytes. failing that,
js_realloc allocates a new region of size nbytes and copies as much of the existing data in p as will fit to the new region. then it frees the region at p and returns a pointer to the new region. apart from whatever is copied, any newly allocated space is uninitialized. ...
...js_strdup allocates a copy of the null-terminated string s. on success, it returns a pointer to the copy. ...
...And 5 more matches
Choosing the right memory allocator
npn_memalloc npn_memfree npn_memflush javascript api memory allocators there are also routines intended for use within the javascript runtime engine (spidermonkey). this is the /js/ subtree of the source code. also, all consumers of the jsapi must use these routines for allocating memory they plan to pass to the javascript runtime. see jsapi reference for further information. js_malloc()
js_realloc() js_free() js_strdup() arena allocators nspr exposes arena allocators that can be used to efficiently allocate lots of small, uniformly sized objects. presshell arena nsipresshell::allocateframe() and nsprescontext::allocatefromshell() can be used to allocate memory from an arena maintained by the presshell. these should only be used to allocate objects that are guaranteed to have a short...
JS::SourceBufferHolder
cters. ownership ownership see description. description js::sourcebufferholder is the container class for passing in script source buffers to the js engine. this not only groups the buffer and length values, it also provides a way to optionally pass ownership of the buffer to the js engine without copying. rules for use: the data array must be allocated with js_malloc or
js_realloc if ownership is being granted to the sourcebufferholder. if ownership is not given to the sourcebufferholder, then the memory must be kept alive until the js compilation is complete. any code calling sourcebufferholder::take() must guarantee to keep the memory alive until js compilation completes. normally only the js engine should be calling take(). example size_t length = 512; char16_t* ch...
JSAPI reference
nce jsapi 34 and functions that behave like the equality operators: js_strictlyequal js_looselyequal js_samevalue memory management these functions act like the standard c malloc family of functions, except that errors are reported using the spidermonkey error apis rather than errno. these functions also allow spidermonkey to account the number of bytes allocated: js_malloc js_free
js_realloc js_strdup struct jsfreeop added in spidermonkey 17 js_freeop added in spidermonkey 17 js_getdefaultfreeop added in spidermonkey 17 javascript objects, strings, and floating-point numbers are garbage collected. these functions provide access to the garbage collector: js_gc js_maybegc js_getgcparameter js_setgcparameter js_getgcparameterforthread added in spidermonkey 17 js_setgcparam...