Skip to content

Commit

Permalink
Add allocator parameter to rand.perm
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Feb 1, 2022
1 parent eac7463 commit 8c95055
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/math/rand/rand.odin
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ read :: proc(p: []byte, r: ^Rand = nil) -> (n: int) {
}

// perm returns a slice of n ints in a pseudo-random permutation of integers in the range [0, n)
perm :: proc(n: int, r: ^Rand = nil) -> []int {
m := make([]int, n)
perm :: proc(n: int, r: ^Rand = nil, allocator := context.allocator) -> []int {
m := make([]int, n, allocator)
for i := 0; i < n; i += 1 {
j := int_max(i+1, r)
m[i] = m[j]
Expand Down

0 comments on commit 8c95055

Please sign in to comment.