-
-
Notifications
You must be signed in to change notification settings - Fork 849
Open
Labels
Description
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:
- Can't control allocator used in procs tagged with
@(init)and globals #5136 - Panic in _startup_runtime in executable built with -default-to-panic-allocator #5336
Already reviewed:
- core\terminal\terminal_windows.odin:20, addressed in Get env buffer #5348
- core\terminal\internal.odin:70, addressed in Get env buffer #5348
- core\net\dns.odin:47, addressed in Allow
core:netto be imported with-default-to-panic-allocator. #5354 - core\os\os2\file_windows.odin:45, doesn't appear to allocate
- core\os\os2\file_posix.odin:27, doesn't appear to allocate
- core\os\os2\path_windows.odin:162, doesn't appear to allocate
- core\os\os2\file_wasi.odin:32, doesn't appear to allocate
- core\os\os2\file_wasi.odin:53, @laytan contends that
os2's own allocators sidestep this issue.
Feoramund, BradLewis, FourteenBrush, greenya, Mecso2 and 1 more