Commits

Anonymous committed b6e72d5

more on arrays realloc

  • Participants
  • Parent commits 9df36ef

Comments (0)

Files changed (1)

File iteratees.ml

 
 
 value array_ensure_size ~default array_ref size =
+  if size < 0 || size > Sys.max_array_length
+  then invalid_arg "Iteratees.array_ensure_size: bad size"
+  else
   let realloc () =
     let new_size =
       loop 1
       where rec loop n =
         if n < size
         then loop (n * 2)
-        else n
+        else min n Sys.max_array_length
     in
     let r = Array.make new_size default in
     ( array_ref.val := r