Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
(hcreate_r): We need at least three elements in the hash table.
  • Loading branch information
Ulrich Drepper committed Jan 23, 2009
1 parent 0699a0c commit 8073a49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion misc/hsearch_r.c
@@ -1,4 +1,4 @@
/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008
/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
Expand Down Expand Up @@ -79,6 +79,10 @@ hcreate_r (nel, htab)
if (htab->table != NULL)
return 0;

/* We need a size of at least 3. Otherwise the hash functions we
use will not work. */
if (nel < 3)
nel = 3;
/* Change nel to the first prime number not smaller as nel. */
nel |= 1; /* make odd */
while (!isprime (nel))
Expand Down

0 comments on commit 8073a49

Please sign in to comment.