Skip to content

Instantly share code, notes, and snippets.

@ysbaddaden
Last active October 13, 2025 09:27
Show Gist options
  • Save ysbaddaden/20186aa2278d1881dcda85902cffe8a8 to your computer and use it in GitHub Desktop.
Save ysbaddaden/20186aa2278d1881dcda85902cffe8a8 to your computer and use it in GitHub Desktop.
`GC.malloc_uninitialized` (untested)
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