JS malloc
From MDC
Allocates a region of memory for use.
[edit] Syntax
void * JS_malloc(JSContext *cx, size_t nbytes);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
Pointer to a JS context. If allocation fails, an error is repored in this context. |
nbytes |
size_t |
Amount of space, in bytes, to allocate. |
[edit] Description
JS_malloc allocates a region of memory nbytes in size. If the allocation is successful, JS_malloc returns a pointer to the beginning of the region.
If the memory cannot be allocated, JS_malloc passes cx to JS_ReportOutOfMemory to report the error and returns NULL.
As with a standard C call to malloc, the region of memory allocated by this call is uninitialized and should be assumed to contain meaningless information.
Implementation note: Currently JS_malloc is a wrapper on the standard C malloc call. Do not make assumptions based on this underlying reliance. Future versions of JS_malloc may be implemented in a different manner.