Mercurial > hg > CbC > GCC_original
comparison gcc/sparseset.c @ 16:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | a06113de4d67 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
15:561a7518be6b | 16:04ced10e8804 |
---|---|
1 /* SparseSet implementation. | 1 /* SparseSet implementation. |
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. | 2 Copyright (C) 2007-2017 Free Software Foundation, Inc. |
3 Contributed by Peter Bergner <bergner@vnet.ibm.com> | 3 Contributed by Peter Bergner <bergner@vnet.ibm.com> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
28 sparseset_alloc (SPARSESET_ELT_TYPE n_elms) | 28 sparseset_alloc (SPARSESET_ELT_TYPE n_elms) |
29 { | 29 { |
30 unsigned int n_bytes = sizeof (struct sparseset_def) | 30 unsigned int n_bytes = sizeof (struct sparseset_def) |
31 + ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE)); | 31 + ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE)); |
32 | 32 |
33 /* We use xcalloc rather than xmalloc to silence some valgrind uninitialized | 33 sparseset set = XNEWVAR (struct sparseset_def, n_bytes); |
34 | |
35 /* Mark the sparseset as defined to silence some valgrind uninitialized | |
34 read errors when accessing set->sparse[n] when "n" is not, and never has | 36 read errors when accessing set->sparse[n] when "n" is not, and never has |
35 been, in the set. These uninitialized reads are expected, by design and | 37 been, in the set. These uninitialized reads are expected, by design and |
36 harmless. If this turns into a performance problem due to some future | 38 harmless. */ |
37 additional users of sparseset, we can revisit this decision. */ | 39 VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED (set, n_bytes)); |
38 sparseset set = (sparseset) xcalloc (1, n_bytes); | 40 |
39 set->dense = &(set->elms[0]); | 41 set->dense = &(set->elms[0]); |
40 set->sparse = &(set->elms[n_elms]); | 42 set->sparse = &(set->elms[n_elms]); |
41 set->size = n_elms; | 43 set->size = n_elms; |
42 sparseset_clear (set); | 44 sparseset_clear (set); |
43 return set; | 45 return set; |