Browse Source

Merge pull request #12 from sajattack/atexit

fix atexit
Jeremy Soller 7 years ago
parent
commit
4f5d65e7a6
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/stdlib/src/lib.rs

+ 3 - 3
src/stdlib/src/lib.rs

@@ -15,7 +15,7 @@ static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
 pub const EXIT_FAILURE: c_int = 1;
 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]
 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 {
 #[no_mangle]
 pub unsafe extern "C" fn atexit(func: Option<extern "C" fn()>) -> c_int {
     for i in 0..ATEXIT_FUNCS.len() {
-        if ATEXIT_FUNCS[i] != None {
-            ATEXIT_FUNCS[i] = Some(func.unwrap() as usize);
+        if ATEXIT_FUNCS[i] == None {
+            ATEXIT_FUNCS[i] = func;
             return 0;
         }
     }