JavaScript-1.5 Reference

JS_malloc Function

Summary

Allocates a region of memory for use.

Syntax

void * JS_malloc(JSContext *cx, size_t nbytes);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
nbytessize_tAmount of space, in bytes, to allocate.

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 a null pointer.

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.

Notes

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.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_ReportOutOfMemory | JS_free | JS_realloc ]

This page was generated by APIDOC