MCPcopy Index your code
hub / github.com/RustPython/RustPython / buffer_to_ptr_len

Function buffer_to_ptr_len

crates/stdlib/src/_sqlite3.rs:3456–3464  ·  view source on GitHub ↗
(buffer: &PyBuffer, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3454 }
3455
3456 fn buffer_to_ptr_len(buffer: &PyBuffer, vm: &VirtualMachine) -> PyResult<(*const c_void, i32)> {
3457 let bytes = buffer
3458 .as_contiguous()
3459 .ok_or_else(|| vm.new_buffer_error("underlying buffer is not C-contiguous"))?;
3460 let len = c_int::try_from(bytes.len())
3461 .map_err(|_| vm.new_overflow_error("BLOB longer than INT_MAX bytes"))?;
3462 let ptr = bytes.as_ptr().cast();
3463 Ok((ptr, len))
3464 }
3465
3466 fn exception_type_from_errcode(errcode: c_int, vm: &VirtualMachine) -> &'static Py<PyType> {
3467 match errcode {

Callers 2

bind_parameterMethod · 0.85
result_from_objectMethod · 0.85

Calls 5

ok_or_elseMethod · 0.80
as_contiguousMethod · 0.45
lenMethod · 0.45
castMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected