default_allocators_wasi.odin 771 B

1234567891011121314151617181920212223242526272829303132
  1. //+build wasi
  2. package runtime
  3. default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
  4. size, alignment: int,
  5. old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) {
  6. switch mode {
  7. case .Alloc:
  8. return nil, .Out_Of_Memory
  9. case .Free:
  10. return nil, .None
  11. case .Free_All:
  12. return nil, .Mode_Not_Implemented
  13. case .Resize:
  14. if size == 0 {
  15. return nil, .None
  16. }
  17. return nil, .Out_Of_Memory
  18. case .Query_Features:
  19. return nil, .Mode_Not_Implemented
  20. case .Query_Info:
  21. return nil, .Mode_Not_Implemented
  22. }
  23. return nil, .None
  24. }
  25. default_allocator :: proc() -> Allocator {
  26. return Allocator{
  27. procedure = default_allocator_proc,
  28. data = nil,
  29. }
  30. }