diff options
Diffstat (limited to 'gcc/ggc-common.c')
-rw-r--r-- | gcc/ggc-common.c | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 3da248b6e40..d00f9032c84 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -140,52 +140,6 @@ ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL) return buf; } -/* Resize a block of memory, possibly re-allocating it. */ -void * -ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL) -{ - void *r; - size_t old_size; - - if (x == NULL) - return ggc_alloc_stat (size PASS_MEM_STAT); - - old_size = ggc_get_size (x); - - if (size <= old_size) - { - /* Mark the unwanted memory as unaccessible. We also need to make - the "new" size accessible, since ggc_get_size returns the size of - the pool, not the size of the individually allocated object, the - size which was previously made accessible. Unfortunately, we - don't know that previously allocated size. Without that - knowledge we have to lose some initialization-tracking for the - old parts of the object. An alternative is to mark the whole - old_size as reachable, but that would lose tracking of writes - after the end of the object (by small offsets). Discard the - handle to avoid handle leak. */ - VALGRIND_DISCARD (VALGRIND_MAKE_NOACCESS ((char *) x + size, - old_size - size)); - VALGRIND_DISCARD (VALGRIND_MAKE_READABLE (x, size)); - return x; - } - - r = ggc_alloc_stat (size PASS_MEM_STAT); - - /* Since ggc_get_size returns the size of the pool, not the size of the - individually allocated object, we'd access parts of the old object - that were marked invalid with the memcpy below. We lose a bit of the - initialization-tracking since some of it may be uninitialized. */ - VALGRIND_DISCARD (VALGRIND_MAKE_READABLE (x, old_size)); - - memcpy (r, x, old_size); - - /* The old object is not supposed to be used anymore. */ - ggc_free (x); - - return r; -} - /* Like ggc_alloc_cleared, but performs a multiplication. */ void * ggc_calloc (size_t s1, size_t s2) |