Skip to content

Commit

Permalink
don't protect r NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa committed Nov 28, 2023
1 parent d75a2bd commit df04cb8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions extendr-api/src/ownership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ use libR_sys::{
static OWNERSHIP: Lazy<Mutex<Ownership>> = Lazy::new(|| Mutex::new(Ownership::new()));

pub(crate) unsafe fn protect(sexp: SEXP) {
let mut own = OWNERSHIP.lock().expect("protect failed");
own.protect(sexp);
if sexp != R_NilValue {
let mut own = OWNERSHIP.lock().expect("protect failed");
own.protect(sexp);
}
}

pub(crate) unsafe fn unprotect(sexp: SEXP) {
let mut own = OWNERSHIP.lock().expect("unprotect failed");
own.unprotect(sexp);
if sexp != R_NilValue {
let mut own = OWNERSHIP.lock().expect("unprotect failed");
own.unprotect(sexp);
}
}

pub const INITIAL_PRESERVATION_SIZE: usize = 100000;
Expand Down

0 comments on commit df04cb8

Please sign in to comment.