default_allocators_general.odin 781 B

123456789101112131415161718192021222324252627282930
  1. //+build !windows
  2. //+build !freestanding
  3. //+build !wasi
  4. package runtime
  5. when ODIN_DEFAULT_TO_NIL_ALLOCATOR {
  6. // mem.nil_allocator reimplementation
  7. default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
  8. size, alignment: int,
  9. old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) {
  10. return nil, .None
  11. }
  12. default_allocator :: proc() -> Allocator {
  13. return Allocator{
  14. procedure = default_allocator_proc,
  15. data = nil,
  16. }
  17. }
  18. } else {
  19. // TODO(bill): reimplement these procedures in the os_specific stuff
  20. import "core:os"
  21. default_allocator_proc :: os.heap_allocator_proc
  22. default_allocator :: proc() -> Allocator {
  23. return os.heap_allocator()
  24. }
  25. }