Browse Source

Add allocator parameter to `rand.perm`

gingerBill 3 years ago
parent
commit
8c9505505a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      core/math/rand/rand.odin

+ 2 - 2
core/math/rand/rand.odin

@@ -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 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 {
 	for i := 0; i < n; i += 1 {
 		j := int_max(i+1, r)
 		j := int_max(i+1, r)
 		m[i] = m[j]
 		m[i] = m[j]