diff options
| author | Barinzaya <barinzaya@gmail.com> | 2025-03-22 10:38:44 -0400 |
|---|---|---|
| committer | Barinzaya <barinzaya@gmail.com> | 2025-03-22 11:03:04 -0400 |
| commit | 7819797a031072e566d080749cca9abf996796fa (patch) | |
| tree | 795ace63ed224ab44a15aa4ce10888aeec669dc5 /core/mem | |
| parent | 7ffbb68fff2df61798c130751dfebe323e8638f9 (diff) | |
Split `mem.make_map` to match the `runtime` procs.
The existing `mem.make_map` passes a capacity, but the builtin
`make_map` no longer takes a capacity--it was separated to
`make_map_cap` to allow for making a map without an allocation (#4340).
`core:mem` was not updated to reflect this, so any usage of `mem.make`
to make a map will currently result in a compile error.
Diffstat (limited to 'core/mem')
| -rw-r--r-- | core/mem/alloc.odin | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index 1094e7381..6dcfb7888 100644 --- a/core/mem/alloc.odin +++ b/core/mem/alloc.odin @@ -954,6 +954,22 @@ make_dynamic_array_len_cap :: proc( } /* +Create a map with no initial allocation. + +This procedure creates a map of type `T` with no initial allocation, which will +use the allocator specified by `allocator` as its backing allocator when it +allocates. +*/ +@(require_results) +make_map :: proc( + $T: typeid/map[$K]$E, + allocator := context.allocator, + loc := #caller_location, +) -> (m: T) { + return runtime.make_map(T, allocator, loc) +} + +/* Allocate a map. This procedure creates a map of type `T` with initial capacity specified by @@ -961,13 +977,13 @@ This procedure creates a map of type `T` with initial capacity specified by allocator. */ @(require_results) -make_map :: proc( +make_map_cap :: proc( $T: typeid/map[$K]$E, - #any_int cap: int = 1<<runtime.MAP_MIN_LOG2_CAPACITY, + #any_int cap: int, allocator := context.allocator, loc := #caller_location, ) -> (m: T, err: Allocator_Error) { - return runtime.make_map(T, cap, allocator, loc) + return runtime.make_map_cap(T, cap, allocator, loc) } /* @@ -1060,6 +1076,7 @@ make :: proc{ make_dynamic_array_len, make_dynamic_array_len_cap, make_map, + make_map_cap, make_multi_pointer, make_soa_slice, make_soa_dynamic_array, |