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

Function ptr_to_vec

crates/stdlib/src/_sqlite3.rs:3429–3446  ·  view source on GitHub ↗
(
        p: *const u8,
        nbytes: c_int,
        db: *mut sqlite3,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

3427 }
3428
3429 fn ptr_to_vec(
3430 p: *const u8,
3431 nbytes: c_int,
3432 db: *mut sqlite3,
3433 vm: &VirtualMachine,
3434 ) -> PyResult<Vec<u8>> {
3435 if p.is_null() {
3436 if !db.is_null() && unsafe { sqlite3_errcode(db) } == SQLITE_NOMEM {
3437 Err(vm.new_memory_error("sqlite out of memory"))
3438 } else {
3439 Ok(vec![])
3440 }
3441 } else if nbytes < 0 {
3442 Err(vm.new_system_error("negative size with ptr"))
3443 } else {
3444 Ok(unsafe { core::slice::from_raw_parts(p.cast(), nbytes as usize) }.to_vec())
3445 }
3446 }
3447
3448 fn str_to_ptr_len(s: &PyUtf8Str, vm: &VirtualMachine) -> PyResult<(*const libc::c_char, i32)> {
3449 let s_str = s.as_str();

Callers 3

nextMethod · 0.85
value_to_objectFunction · 0.85
ptr_to_stringFunction · 0.85

Calls 3

to_vecMethod · 0.80
ErrClass · 0.50
castMethod · 0.45

Tested by

no test coverage detected