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

Function getrlimit

crates/stdlib/src/resource.rs:156–169  ·  view source on GitHub ↗
(resource: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

154
155 #[pyfunction]
156 fn getrlimit(resource: i32, vm: &VirtualMachine) -> PyResult<Limits> {
157 #[allow(clippy::unnecessary_cast)]
158 if resource < 0 || resource >= RLIM_NLIMITS as i32 {
159 return Err(vm.new_value_error("invalid resource specified"));
160 }
161 let rlimit = unsafe {
162 let mut rlimit = mem::MaybeUninit::<libc::rlimit>::uninit();
163 if libc::getrlimit(resource as _, rlimit.as_mut_ptr()) == -1 {
164 return Err(vm.new_last_errno_error());
165 }
166 rlimit.assume_init()
167 };
168 Ok(Limits(rlimit))
169 }
170
171 #[pyfunction]
172 fn setrlimit(resource: i32, limits: Limits, vm: &VirtualMachine) -> PyResult<()> {

Callers 1

Calls 4

LimitsClass · 0.85
as_mut_ptrMethod · 0.80
new_last_errno_errorMethod · 0.80
ErrClass · 0.50

Tested by 1