Performs comprehensive validation of FFI call inputs before making the call. This helps diagnose issues that would otherwise cause crashes.
Usage
ffi_validate_call(cif, symbol, args = list(), verbose = FALSE)Value
A list with validation results:
- valid
Logical; TRUE if all checks pass
- errors
Character vector of error messages (empty if valid)
- warnings
Character vector of warning messages
Details
This function checks:
CIF and symbol pointers are not NULL
Argument count matches CIF specification
No NA values in arguments (unless explicitly allowed)
Pointer arguments are not NULL (when applicable)
Note that even with all checks passing, crashes can still occur if:
The C function signature doesn't match the CIF
Pointer arguments point to invalid memory
Buffer sizes are incorrect
The C function itself has bugs