diff options
author | Tom Tromey <tromey@redhat.com> | 2003-01-23 17:40:42 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-01-23 17:40:42 +0000 |
commit | 0f0ff6ec541f245d32475c7dabe65d2a303a7fdd (patch) | |
tree | 776cef2837a148db4d5f6a975fa6091c4391523b /gcc/java/constants.c | |
parent | 9a600d0c7f8c12236fd1e7fd060c0586c6211d9f (diff) | |
download | gcc-0f0ff6ec541f245d32475c7dabe65d2a303a7fdd.zip gcc-0f0ff6ec541f245d32475c7dabe65d2a303a7fdd.tar.gz gcc-0f0ff6ec541f245d32475c7dabe65d2a303a7fdd.tar.bz2 |
* constants.c (set_constant_entry): Allocated cleared memory.
From-SVN: r61661
Diffstat (limited to 'gcc/java/constants.c')
-rw-r--r-- | gcc/java/constants.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/java/constants.c b/gcc/java/constants.c index cdf307c..1a56df0 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -46,12 +46,14 @@ set_constant_entry (CPool *cpool, int index, int tag, jword value) if (cpool->data == NULL) { cpool->capacity = 100; - cpool->tags = ggc_alloc (sizeof(uint8) * cpool->capacity); - cpool->data = ggc_alloc (sizeof(union cpool_entry) * cpool->capacity); + cpool->tags = ggc_alloc_cleared (sizeof(uint8) * cpool->capacity); + cpool->data = ggc_alloc_cleared (sizeof(union cpool_entry) + * cpool->capacity); cpool->count = 1; } if (index >= cpool->capacity) { + int old_cap = cpool->capacity; cpool->capacity *= 2; if (index >= cpool->capacity) cpool->capacity = index + 10; @@ -59,6 +61,11 @@ set_constant_entry (CPool *cpool, int index, int tag, jword value) sizeof(uint8) * cpool->capacity); cpool->data = ggc_realloc (cpool->data, sizeof(union cpool_entry) * cpool->capacity); + + /* Make sure GC never sees uninitialized tag values. */ + memset (cpool->tags + old_cap, 0, cpool->capacity - old_cap); + memset (cpool->data + old_cap, 0, + (cpool->capacity - old_cap) * sizeof (union cpool_entry)); } if (index >= cpool->count) cpool->count = index + 1; |