diff --git a/cmd/tools/test_if_v_test_system_works.v b/cmd/tools/test_if_v_test_system_works.v index 61877ddf5c..92d2ae0dbf 100644 --- a/cmd/tools/test_if_v_test_system_works.v +++ b/cmd/tools/test_if_v_test_system_works.v @@ -27,7 +27,7 @@ fn new_tdir() string { dir := os.join_path(os.vtmp_dir(), rand.ulid()) os.rmdir_all(dir) or {} os.mkdir_all(dir) or { panic(err) } - C.atexit(cleanup_tdir) + at_exit(cleanup_tdir) or {} return dir } diff --git a/cmd/tools/vsymlink.v b/cmd/tools/vsymlink.v index 23378fd262..09fb3f4fe0 100644 --- a/cmd/tools/vsymlink.v +++ b/cmd/tools/vsymlink.v @@ -8,7 +8,7 @@ $if windows { } fn main() { - C.atexit(cleanup_vtmp_folder) + at_exit(cleanup_vtmp_folder) or {} if os.args.len > 3 { print('usage: v symlink [OPTIONS]') diff --git a/vlib/builtin/builtin_windows.c.v b/vlib/builtin/builtin_windows.c.v index 302c66f969..823e648d9e 100644 --- a/vlib/builtin/builtin_windows.c.v +++ b/vlib/builtin/builtin_windows.c.v @@ -53,7 +53,7 @@ fn builtin_init() { } g_original_codepage = C.GetConsoleOutputCP() C.SetConsoleOutputCP(cp_utf8) - C.atexit(restore_codepage) + at_exit(restore_codepage) or {} if is_terminal(1) > 0 { C.SetConsoleMode(C.GetStdHandle(std_output_handle), enable_processed_output | enable_wrap_at_eol_output | evable_virtual_terminal_processing) C.SetConsoleMode(C.GetStdHandle(std_error_handle), enable_processed_output | enable_wrap_at_eol_output | evable_virtual_terminal_processing) diff --git a/vlib/builtin/prealloc.c.v b/vlib/builtin/prealloc.c.v index da3ab07a19..5e45fd5d51 100644 --- a/vlib/builtin/prealloc.c.v +++ b/vlib/builtin/prealloc.c.v @@ -66,9 +66,7 @@ fn vmemory_block_malloc(n isize) &u8 { fn prealloc_vinit() { unsafe { g_memory_block = vmemory_block_new(nil, prealloc_block_size) - $if !freestanding { - C.atexit(prealloc_vcleanup) - } + at_exit(prealloc_vcleanup) or {} } } diff --git a/vlib/log/default.c.v b/vlib/log/default.c.v index 8ea06573c0..feb30be10f 100644 --- a/vlib/log/default.c.v +++ b/vlib/log/default.c.v @@ -16,7 +16,7 @@ mut: // init will be called before the user's main program starts, to initialize the default logger fn init() { default_logger = new_thread_safe_log() - C.atexit(deinit) + at_exit(deinit) or {} } // deinit will be called on exit of the program and will free the memory allocated for the default logger diff --git a/vlib/rand/rand.c.v b/vlib/rand/rand.c.v index 5b1cf47e95..58a74397e8 100644 --- a/vlib/rand/rand.c.v +++ b/vlib/rand/rand.c.v @@ -133,7 +133,7 @@ fn deinit() { // init initializes the default RNG. fn init() { default_rng = new_default() - C.atexit(deinit) + at_exit(deinit) or {} } fn read_32(mut rng PRNG, mut buf []u8) { diff --git a/vlib/term/ui/input_windows.c.v b/vlib/term/ui/input_windows.c.v index 91cecd94d9..beaeeeb4f1 100644 --- a/vlib/term/ui/input_windows.c.v +++ b/vlib/term/ui/input_windows.c.v @@ -82,7 +82,7 @@ pub fn init(cfg Config) &Context { } ctx_ptr = ctx - C.atexit(restore_terminal_state) + at_exit(restore_terminal_state) or {} for code in ctx.cfg.reset { os.signal_opt(code, fn (_ os.Signal) { mut c := ctx_ptr diff --git a/vlib/term/ui/termios_nix.c.v b/vlib/term/ui/termios_nix.c.v index 989397effc..9589a82fb5 100644 --- a/vlib/term/ui/termios_nix.c.v +++ b/vlib/term/ui/termios_nix.c.v @@ -115,7 +115,7 @@ fn (mut ctx Context) termios_setup() ! { ctx.window_height, ctx.window_width = get_terminal_size() // Reset console on exit - C.atexit(restore_terminal_state) + at_exit(restore_terminal_state) or {} os.signal_opt(.tstp, restore_terminal_state_signal) or {} os.signal_opt(.cont, fn (_ os.Signal) { mut c := ctx_ptr diff --git a/vlib/v/dotgraph/dotgraph.c.v b/vlib/v/dotgraph/dotgraph.c.v index a98f7d8949..6a3bbf8c5d 100644 --- a/vlib/v/dotgraph/dotgraph.c.v +++ b/vlib/v/dotgraph/dotgraph.c.v @@ -2,7 +2,7 @@ module dotgraph pub fn start_digraph() { println('digraph G {') - C.atexit(fn () { + at_exit(fn () { println('}') - }) + }) or {} }