Skip to content
Snippets Groups Projects
Unverified Commit 4f5d65e7 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #12 from sajattack/atexit

fix atexit
parents e2695b23 ef9545cf
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ static ALLOCATOR: ralloc::Allocator = ralloc::Allocator; ...@@ -15,7 +15,7 @@ static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
pub const EXIT_FAILURE: c_int = 1; pub const EXIT_FAILURE: c_int = 1;
pub const EXIT_SUCCESS: c_int = 0; pub const EXIT_SUCCESS: c_int = 0;
static mut ATEXIT_FUNCS: [Option<usize>; 32] = [None; 32]; static mut ATEXIT_FUNCS: [Option<extern "C" fn()>; 32] = [None; 32];
#[no_mangle] #[no_mangle]
pub extern "C" fn a64l(s: *const c_char) -> c_long { pub extern "C" fn a64l(s: *const c_char) -> c_long {
...@@ -41,8 +41,8 @@ pub extern "C" fn abs(i: c_int) -> c_int { ...@@ -41,8 +41,8 @@ pub extern "C" fn abs(i: c_int) -> c_int {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn atexit(func: Option<extern "C" fn()>) -> c_int { pub unsafe extern "C" fn atexit(func: Option<extern "C" fn()>) -> c_int {
for i in 0..ATEXIT_FUNCS.len() { for i in 0..ATEXIT_FUNCS.len() {
if ATEXIT_FUNCS[i] != None { if ATEXIT_FUNCS[i] == None {
ATEXIT_FUNCS[i] = Some(func.unwrap() as usize); ATEXIT_FUNCS[i] = func;
return 0; return 0;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment