From d101d913a2aba2ce08d68ed0b9c3d4008ff4b804 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 4 Mar 2013 19:10:06 +0100 Subject: [PATCH] bound size of hashtable with Sys.max_rray_length --- pHashtbl.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pHashtbl.ml b/pHashtbl.ml index 515ea44f..b342ecc4 100644 --- a/pHashtbl.ml +++ b/pHashtbl.ml @@ -96,7 +96,8 @@ let insert ~eq buckets h key value = (** Resize the array, by inserting its content into twice as large an array *) let resize ~eq ~hash buckets = - let buckets' = Array.make (Array.length buckets * 2) (my_null ()) in + let new_size = min (Array.length buckets * 2 + 1) Sys.max_array_length in + let buckets' = Array.make new_size (my_null ()) in for i = 0 to Array.length buckets - 1 do match buckets.(i) with | (key, value, Used) ->