Last active
October 13, 2025 09:27
-
-
Save ysbaddaden/20186aa2278d1881dcda85902cffe8a8 to your computer and use it in GitHub Desktop.
`GC.malloc_uninitialized` (untested)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lib LibGC | |
| GC_DS_LENGTH = 0 | |
| fun GC_new_free_list : Void** | |
| fun GC_new_kind(freelist : Void**, descr : GC_word, adjust : Int, clear : Int) : UInt | |
| fun GC_generic_malloc(SizeT, knd : UInt) : Void* | |
| end | |
| module GC | |
| UNINITIALIZED_OBJ_KIND = LibGC.GC_new_kind(LibGC.GC_new_free_list, descr: LibGC::GC_DS_LENGTH, adjust: 1, clear: 0) | |
| # Same as `.malloc` but doesn't zero the memory. | |
| def self.malloc_uninitialized(size : LibC::SizeT) : Void* | |
| LibGC.GC_malloc_generic(size, UNINITIALIZED_OBJ_KIND) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment