Skip to main content

js_malloc_usable_size

Function js_malloc_usable_size 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn js_malloc_usable_size( _ctx: *mut JsContext, ptr: *const c_void, ) -> usize
Expand description

js_malloc_usable_size: how big a block actually is.

Ours records the requested size rather than the allocation’s, so this answers what was asked for. The reference answers the same number for its small blocks and a rounded one for large ones; nothing in the C API depends on the difference — quickjs-libc.c uses it only to size a read.

§Safety

ptr must be null or a live pointer from the js_malloc family.