Skip to content

Commit

Permalink
all: replace usages of C.atexit(cb) with at_exit(cb) or {} (part 2) (
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Apr 12, 2024
1 parent 2a65139 commit a8d0cdd
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/tools/test_if_v_test_system_works.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vsymlink.v
Original file line number Diff line number Diff line change
Expand Up @@ -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]')
Expand Down
2 changes: 1 addition & 1 deletion vlib/builtin/builtin_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions vlib/builtin/prealloc.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion vlib/log/default.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vlib/rand/rand.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion vlib/term/ui/input_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vlib/term/ui/termios_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/dotgraph/dotgraph.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module dotgraph

pub fn start_digraph() {
println('digraph G {')
C.atexit(fn () {
at_exit(fn () {
println('}')
})
}) or {}
}

0 comments on commit a8d0cdd

Please sign in to comment.