|
@@ -35,4 +35,52 @@ nil_allocator :: proc() -> Allocator {
|
|
when ODIN_OS == .Freestanding {
|
|
when ODIN_OS == .Freestanding {
|
|
default_allocator_proc :: nil_allocator_proc
|
|
default_allocator_proc :: nil_allocator_proc
|
|
default_allocator :: nil_allocator
|
|
default_allocator :: nil_allocator
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+panic_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
|
|
|
|
+ size, alignment: int,
|
|
|
|
+ old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) {
|
|
|
|
+ switch mode {
|
|
|
|
+ case .Alloc:
|
|
|
|
+ if size > 0 {
|
|
|
|
+ panic("panic allocator, .Alloc called", loc=loc)
|
|
|
|
+ }
|
|
|
|
+ case .Alloc_Non_Zeroed:
|
|
|
|
+ if size > 0 {
|
|
|
|
+ panic("panic allocator, .Alloc_Non_Zeroed called", loc=loc)
|
|
|
|
+ }
|
|
|
|
+ case .Resize:
|
|
|
|
+ if size > 0 {
|
|
|
|
+ panic("panic allocator, .Resize called", loc=loc)
|
|
|
|
+ }
|
|
|
|
+ case .Free:
|
|
|
|
+ if old_memory != nil {
|
|
|
|
+ panic("panic allocator, .Free called", loc=loc)
|
|
|
|
+ }
|
|
|
|
+ case .Free_All:
|
|
|
|
+ panic("panic allocator, .Free_All called", loc=loc)
|
|
|
|
+
|
|
|
|
+ case .Query_Features:
|
|
|
|
+ set := (^Allocator_Mode_Set)(old_memory)
|
|
|
|
+ if set != nil {
|
|
|
|
+ set^ = {.Query_Features}
|
|
|
|
+ }
|
|
|
|
+ return nil, nil
|
|
|
|
+
|
|
|
|
+ case .Query_Info:
|
|
|
|
+ panic("panic allocator, .Query_Info called", loc=loc)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return nil, nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+panic_allocator :: proc() -> Allocator {
|
|
|
|
+ return Allocator{
|
|
|
|
+ procedure = nil_allocator_proc,
|
|
|
|
+ data = nil,
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|