Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: replace usages of C.atexit(cb) with at_exit(cb) or {} (part 2) #21263

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}
}