summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Weis <Pierre.Weis@inria.fr>1997-02-04 08:02:34 +0000
committerPierre Weis <Pierre.Weis@inria.fr>1997-02-04 08:02:34 +0000
commit430e94aa722046550c50a3a8bb01a731ca9fc897 (patch)
treeac333beea82b707c7d5b1f41e317e5dcd8d9e5b6
parentd03774a5a047d89d8f793cc70862065eaebb7849 (diff)
Test explicite de la taille minimale des tables de hachage.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1256 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--stdlib/hashtbl.ml1
-rw-r--r--stdlib/hashtbl.mli3
2 files changed, 3 insertions, 1 deletions
diff --git a/stdlib/hashtbl.ml b/stdlib/hashtbl.ml
index ba5995b3e..fd8574d93 100644
--- a/stdlib/hashtbl.ml
+++ b/stdlib/hashtbl.ml
@@ -29,6 +29,7 @@ and ('a, 'b) bucketlist =
| Cons of 'a * 'b * ('a, 'b) bucketlist
let create initial_size =
+ if initial_size <= 0 then invalid_arg "hashtbl__new" else
{ max_len = 3; data = Array.create initial_size Empty }
let clear h =
diff --git a/stdlib/hashtbl.mli b/stdlib/hashtbl.mli
index c3bf841ca..10096c9fa 100644
--- a/stdlib/hashtbl.mli
+++ b/stdlib/hashtbl.mli
@@ -24,7 +24,8 @@ val create : int -> ('a,'b) t
(* [Hashtbl.create n] creates a new, empty hash table, with
initial size [n]. The table grows as needed, so [n] is
just an initial guess. Better results are said to be
- achieved when [n] is a prime number. *)
+ achieved when [n] is a prime number.
+ Raise [Invalid_argument "hashtbl__new"] if [n] is less than 1. *)
val clear : ('a, 'b) t -> unit
(* Empty a hash table. *)