projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vasnprintf: Fix crash in %ls directive.
[gnulib.git]
/
lib
/
gl_anyhash_list2.h
diff --git
a/lib/gl_anyhash_list2.h
b/lib/gl_anyhash_list2.h
index
d719116
..
4313581
100644
(file)
--- a/
lib/gl_anyhash_list2.h
+++ b/
lib/gl_anyhash_list2.h
@@
-1,11
+1,11
@@
/* Sequential list data type implemented by a hash table with another list.
/* Sequential list data type implemented by a hash table with another list.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006
, 2009, 2010
Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
Written by Bruno Haible <bruno@clisp.org>, 2006.
- This program is free software
;
you can redistribute it and/or modify
+ This program is free software
:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version
2, or (at your option)
- any later version.
+ the Free Software Foundation; either version
3 of the License, or
+
(at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-13,8
+13,7
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Common code of
gl_linkedhash_list.c, gl_avltreehash_list.c, gl_rbtreehash_list.c. */
/* Common code of
gl_linkedhash_list.c, gl_avltreehash_list.c, gl_rbtreehash_list.c. */
@@
-100,28
+99,40
@@
hash_resize (gl_list_t list, size_t estimate)
{
gl_hash_entry_t *old_table = list->table;
/* Allocate the new table. */
{
gl_hash_entry_t *old_table = list->table;
/* Allocate the new table. */
- gl_hash_entry_t *new_table
= XCALLOC (new_size, gl_hash_entry_t)
;
+ gl_hash_entry_t *new_table;
size_t i;
size_t i;
+ if (size_overflow_p (xtimes (new_size, sizeof (gl_hash_entry_t))))
+ goto fail;
+ new_table =
+ (gl_hash_entry_t *) calloc (new_size, sizeof (gl_hash_entry_t));
+ if (new_table == NULL)
+ goto fail;
+
/* Iterate through the entries of the old table. */
for (i = list->table_size; i > 0; )
/* Iterate through the entries of the old table. */
for (i = list->table_size; i > 0; )
- {
- gl_hash_entry_t node = old_table[--i];
+
{
+
gl_hash_entry_t node = old_table[--i];
- while (node != NULL)
- {
- gl_hash_entry_t next = node->hash_next;
- /* Add the entry to the new table. */
- size_t bucket = node->hashcode % new_size;
- node->hash_next = new_table[bucket];
- new_table[bucket] = node;
+
while (node != NULL)
+
{
+
gl_hash_entry_t next = node->hash_next;
+
/* Add the entry to the new table. */
+
size_t bucket = node->hashcode % new_size;
+
node->hash_next = new_table[bucket];
+
new_table[bucket] = node;
- node = next;
- }
- }
+
node = next;
+
}
+
}
list->table = new_table;
list->table_size = new_size;
free (old_table);
}
list->table = new_table;
list->table_size = new_size;
free (old_table);
}
+ return;
+
+ fail:
+ /* Just continue without resizing the table. */
+ return;
}
}