File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ std/sync:
101101std/static_array:
102102- Add `sarray_pop_first` and `sarray_erase_keep_order`.
103103
104+ std/array
105+ - Add `make_temporary_array`.
106+
104107[Documentation]
105108- Add documentation for comptime call.
106109- Add documentation for static if.
Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ array_terminate :: fn (_arr: *[..]?T) #inline {
8181 arr.allocated_elems = 0;
8282}
8383
84+ /// Returns new dynamic array `[..]TElem` initialized to use current `application_context.temporary_allocator`.
85+ /// The `expected_element_count` can be used to preallocate elements in advance.
86+ make_temporary_array :: fn (TElem: type #comptime, expected_element_count: s64 = 0) [..]TElem #inline {
87+ arr: [..]TElem;
88+ array_init(&arr, expected_element_count, application_context.temporary_allocator);
89+ return arr;
90+ }
91+
8492/// Append new value at the dynamic array end. New heap allocation is done here only in cases when
8593/// there is not enough memory allocated to store all values.
8694/// Returns pointer to the new appended element.
You can’t perform that action at this time.
0 commit comments