mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
all: replace usages of C.atexit(cb) with at_exit(cb) or {}
(part 2) (#21263)
This commit is contained in:
parent
2a651396cf
commit
a8d0cdd31b
@ -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
|
||||
}
|
||||
|
||||
|
@ -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]')
|
||||
|
@ -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)
|
||||
|
@ -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 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -2,7 +2,7 @@ module dotgraph
|
||||
|
||||
pub fn start_digraph() {
|
||||
println('digraph G {')
|
||||
C.atexit(fn () {
|
||||
at_exit(fn () {
|
||||
println('}')
|
||||
})
|
||||
}) or {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user