/* SparseSet implementation.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc.
Contributed by Peter Bergner <bergner@vnet.ibm.com>
This file is part of GCC.
unsigned int n_bytes = sizeof (struct sparseset_def)
+ ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE));
- sparseset set = (sparseset) xmalloc (n_bytes);
+ /* We use xcalloc rather than xmalloc to silence some valgrind uninitialized
+ read errors when accessing set->sparse[n] when "n" is not, and never has
+ been, in the set. These uninitialized reads are expected, by design and
+ harmless. If this turns into a performance problem due to some future
+ additional users of sparseset, we can revisit this decision. */
+ sparseset set = (sparseset) xcalloc (1, n_bytes);
set->dense = &(set->elms[0]);
set->sparse = &(set->elms[n_elms]);
set->size = n_elms;