diff options
author | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-31 02:18:25 +0000 |
---|---|---|
committer | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-31 02:18:25 +0000 |
commit | c84c7b2135d0a3bc90f38d411e3053dc4c0b6e64 (patch) | |
tree | 61737e5c49c00ed5d979ac9af802fa5f8e8f2a48 /gcc/ggc-zone.c | |
parent | 934f2848e83866e4a608ce734a9deceb04e00de6 (diff) | |
download | gcc-c84c7b2135d0a3bc90f38d411e3053dc4c0b6e64.tar.gz |
2003-01-30 Daniel Berlin <dberlin@dberlin.org>
* ggc-zone.c (ggc_free): New function.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@77019 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-zone.c')
-rw-r--r-- | gcc/ggc-zone.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/gcc/ggc-zone.c b/gcc/ggc-zone.c index 355414fcbbc..bc7a4cd899b 100644 --- a/gcc/ggc-zone.c +++ b/gcc/ggc-zone.c @@ -126,6 +126,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #ifndef HOST_BITS_PER_PTR #define HOST_BITS_PER_PTR HOST_BITS_PER_LONG #endif + #ifdef COOKIE_CHECKING #define CHUNK_MAGIC 0x95321123 #define DEADCHUNK_MAGIC 0x12817317 @@ -734,6 +735,31 @@ ggc_alloc_zone (size_t size, struct alloc_zone *zone) return ggc_alloc_zone_1 (size, zone, -1); } +/* Poison the chunk. */ +#ifdef ENABLE_GC_CHECKING +#define poison_chunk(CHUNK, SIZE) \ + memset ((CHUNK)->u.data, 0xa5, (SIZE)) +#else +#define poison_chunk(CHUNK, SIZE) +#endif + +/* Free the object at P. */ + +void +ggc_free (void *p) +{ + struct alloc_chunk *chunk; + + chunk = (struct alloc_chunk *) ((char *)p - CHUNK_OVERHEAD); + + /* Poison the chunk. */ + poison_chunk (chunk, ggc_get_size (p)); + + /* XXX: We only deal with explicitly freeing large objects ATM. */ + if (chunk->large) + free (p); +} + /* If P is not marked, mark it and return false. Otherwise return true. P must have been allocated by the GC allocator; it mustn't point to static objects, stack variables, or memory allocated with malloc. */ @@ -931,13 +957,6 @@ ggc_pop_context (void) for (zone = G.zones; zone; zone = zone->next_zone) ggc_pop_context_1 (zone); } -/* Poison the chunk. */ -#ifdef ENABLE_GC_CHECKING -#define poison_chunk(CHUNK, SIZE) \ - memset ((CHUNK)->u.data, 0xa5, (SIZE)) -#else -#define poison_chunk(CHUNK, SIZE) -#endif /* Free all empty pages and objects within a page for a given zone */ |