Odin icon indicating copy to clipboard operation
Odin copied to clipboard

`@(init)` tracking issue

Open Kelimion opened this issue 6 months ago • 2 comments

As a general rule and strong preference, we would like @(init) procedures not to require the context.allocator or context.temp_allocator unless absolutely necessary. This is so that projects can be compiled using -default-to-nil-allocator (or -default-to-panic-allocator) to vouchsafe that any allocation occurs on custom allocators set up in main().

We will want to review any newly added use of @(init) and propose changes to avoid allocation where practical. Alternatives include using temporary stack buffers, adding sync.do_once to a procedure that expects something to be initialized, and so forth.

See for example:

  • [x] #5136
  • [x] #5336

Already reviewed:

  • [X] core\terminal\terminal_windows.odin:20, addressed in #5348
  • [X] core\terminal\internal.odin:70, addressed in #5348
  • [X] core\net\dns.odin:47, addressed in #5354
  • [X] core\os\os2\file_windows.odin:45, doesn't appear to allocate
  • [X] core\os\os2\file_posix.odin:27, doesn't appear to allocate
  • [X] core\os\os2\path_windows.odin:162, doesn't appear to allocate
  • [X] core\os\os2\file_wasi.odin:32, doesn't appear to allocate
  • [X] core\os\os2\file_wasi.odin:53, @laytan contends that os2's own allocators sidestep this issue.

Kelimion avatar Jun 17 '25 10:06 Kelimion