Merge pull request #531 from Tetralux/fix-make-and-reserve

Fix make and reserve
This commit is contained in:
gingerBill
2020-01-03 10:51:42 +00:00
committed by GitHub
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -124,8 +124,10 @@ make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, auto_cast len: int, alloc
make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, auto_cast len: int, auto_cast cap: int, allocator := context.allocator, loc := #caller_location) -> T {
runtime.make_dynamic_array_error_loc(loc, len, cap);
data := alloc(size_of(E)*cap, align_of(E), allocator, loc);
if data == nil do return nil;
s := Raw_Dynamic_Array{data, len, cap, allocator};
if data == nil {
s.len, s.cap = 0, 0;
}
return transmute(T)s;
}
make_map :: proc($T: typeid/map[$K]$E, auto_cast cap: int = 16, allocator := context.allocator, loc := #caller_location) -> T {
+3 -1
View File
@@ -628,8 +628,10 @@ make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, auto_cast len: int, alloc
make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, auto_cast len: int, auto_cast cap: int, allocator := context.allocator, loc := #caller_location) -> T {
make_dynamic_array_error_loc(loc, len, cap);
data := mem_alloc(size_of(E)*cap, align_of(E), allocator, loc);
if data == nil do return nil;
s := Raw_Dynamic_Array{data, len, cap, allocator};
if data == nil {
s.len, s.cap = 0, 0;
}
return transmute(T)s;
}