#[unsafe(no_mangle)]pub unsafe extern "C" fn ifc_lite_parse(
path_ptr: *const u8,
path_len: usize,
out_ptr: *mut *mut u8,
out_len: *mut usize,
) -> i32Expand description
Parse an IFC file and return JSON bytes.
§Arguments
path_ptr/path_len: UTF-8 encoded file pathout_ptr: receives pointer to allocated JSON bytesout_len: receives length of allocated JSON bytes
§Returns
0on success1if a pointer is null or the path is invalid UTF-82if the file cannot be read3if parsing panics or the worker pool cannot be started (a panic is only recoverable in an unwinding build such asserver-release; see the module header)4if JSON serialization fails
On 0, *out_ptr / *out_len describe the buffer. On every other code,
each of them that is non-null is set to null / 0, so a host may free on
“non-null” without re-zeroing between calls (ifc_lite_free(NULL, 0) is a
no-op).
§Safety
path_ptrmust be valid for reads ofpath_lenbytes, all inside one allocation, andpath_lenmust not exceedisize::MAX.path_lenis a count of UTF-8 bytes: passing a UTF-16 length (a .NETstring.Length) for a non-ASCII path reads past the buffer. Only a nullpath_ptris detected; a wrong length is undefined behaviour, not error1.out_ptrandout_lenmust each be null or valid for writes and properly aligned. Their storage must not overlap each other or the allocation behindpath_ptr: both are written before the path is read.- A buffer returned on
0must be freed exactly once, withifc_lite_freeand the same*out_len.