aboutsummaryrefslogtreecommitdiff
path: root/core/mem/alloc.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-08-16 22:07:40 +0100
committergingerBill <bill@gingerbill.org>2020-08-16 22:07:40 +0100
commit033b46def884b94d3095f1f4fb71ca9cf0819081 (patch)
tree13d510a3d499533524a2fd56681ca88a50a3a433 /core/mem/alloc.odin
parent1f571f48e5c3cf823f068e464324ff218314498f (diff)
Add `mem.Allocator_Mode.Query_Features, `mem.Allocator_Mode_Set`, `mem.query_features`
Diffstat (limited to 'core/mem/alloc.odin')
-rw-r--r--core/mem/alloc.odin18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin
index 80969aa1f..0ed691dd6 100644
--- a/core/mem/alloc.odin
+++ b/core/mem/alloc.odin
@@ -10,9 +10,15 @@ Allocator_Mode :: enum byte {
Free,
Free_All,
Resize,
+ Query_Features,
}
*/
+Allocator_Mode_Set :: runtime.Allocator_Mode_Set;
+/*
+Allocator_Mode_Set :: distinct bit_set[Allocator_Mode];
+*/
+
Allocator_Proc :: runtime.Allocator_Proc;
/*
Allocator_Proc :: #type proc(allocator_data: rawptr, mode: Allocator_Mode,
@@ -63,6 +69,18 @@ resize :: inline proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEF
return allocator.procedure(allocator.data, Allocator_Mode.Resize, new_size, alignment, ptr, old_size, 0, loc);
}
+query_features :: proc(allocator: Allocator, loc := #caller_location) -> Allocator_Mode_Set {
+ if allocator.procedure != nil {
+ set: Allocator_Mode_Set;
+ res := allocator.procedure(allocator.data, Allocator_Mode.Query_Features, 0, 0, &set, 0, 0, loc);
+ if res == &set {
+ return set;
+ }
+ }
+ return nil;
+}
+
+
delete_string :: proc(str: string, allocator := context.allocator, loc := #caller_location) {
free(raw_data(str), allocator, loc);