ifc_lite_parse

Function ifc_lite_parse 

Source
#[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, ) -> i32
Expand description

Parse an IFC file and return JSON bytes.

§Arguments

  • path_ptr / path_len: UTF-8 encoded file path
  • out_ptr: receives pointer to allocated JSON bytes
  • out_len: receives length of allocated JSON bytes

§Returns

  • 0 on success
  • 1 if a pointer is null or the path is invalid UTF-8
  • 2 if the file cannot be read
  • 3 if parsing panics or the worker pool cannot be started (a panic is only recoverable in an unwinding build such as server-release; see the module header)
  • 4 if 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_ptr must be valid for reads of path_len bytes, all inside one allocation, and path_len must not exceed isize::MAX. path_len is a count of UTF-8 bytes: passing a UTF-16 length (a .NET string.Length) for a non-ASCII path reads past the buffer. Only a null path_ptr is detected; a wrong length is undefined behaviour, not error 1.
  • out_ptr and out_len must each be null or valid for writes and properly aligned. Their storage must not overlap each other or the allocation behind path_ptr: both are written before the path is read.
  • A buffer returned on 0 must be freed exactly once, with ifc_lite_free and the same *out_len.