mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Add Query_Info to Buddy_Allocator
This commit is contained in:
@@ -1116,12 +1116,24 @@ buddy_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
|
|||||||
case .Query_Features:
|
case .Query_Features:
|
||||||
set := (^Allocator_Mode_Set)(old_memory)
|
set := (^Allocator_Mode_Set)(old_memory)
|
||||||
if set != nil {
|
if set != nil {
|
||||||
set^ = {.Query_Features, .Alloc, .Alloc_Non_Zeroed, .Resize, .Resize_Non_Zeroed, .Free, .Free_All}
|
set^ = {.Query_Features, .Alloc, .Alloc_Non_Zeroed, .Resize, .Resize_Non_Zeroed, .Free, .Free_All, .Query_Info}
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
||||||
case .Query_Info:
|
case .Query_Info:
|
||||||
return nil, .Mode_Not_Implemented
|
info := (^Allocator_Query_Info)(old_memory)
|
||||||
|
if info != nil && info.pointer != nil {
|
||||||
|
ptr := old_memory
|
||||||
|
if !(b.head <= ptr && ptr <= b.tail) {
|
||||||
|
return nil, .Invalid_Pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
block := (^Buddy_Block)(([^]byte)(ptr)[-b.alignment:])
|
||||||
|
info.size = int(block.size)
|
||||||
|
info.alignment = int(b.alignment)
|
||||||
|
return byte_slice(info, size_of(info^)), nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user