default_allocators_general.odin 766 B

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