Commit 8b07361e by Jan Hubicka Committed by Jan Hubicka

alloc-pool.c (align_four): Kill.

	* alloc-pool.c (align_four): Kill.
	(create_alloc_pool): Align size to eight.
	(free_alloc_pool, free_pool): Invalidate deallocated data.

From-SVN: r76456
parent e129d93a
2004-01-23 Jan Hubicka <jh@suse.cz>
* alloc-pool.c (align_four): Kill.
(create_alloc_pool): Align size to eight.
(free_alloc_pool, free_pool): Invalidate deallocated data.
2004-01-23 Ian Lance Taylor <ian@wasabisystems.com> 2004-01-23 Ian Lance Taylor <ian@wasabisystems.com>
PR gcc/1532 PR gcc/1532
......
...@@ -34,7 +34,6 @@ extern void fancy_abort (const char *, int, const char *) ...@@ -34,7 +34,6 @@ extern void fancy_abort (const char *, int, const char *)
ATTRIBUTE_NORETURN; ATTRIBUTE_NORETURN;
#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
#define align_four(x) (((x+3) >> 2) << 2)
#define align_eight(x) (((x+7) >> 3) << 3) #define align_eight(x) (((x+7) >> 3) << 3)
/* The internal allocation object. */ /* The internal allocation object. */
...@@ -90,7 +89,7 @@ create_alloc_pool (const char *name, size_t size, size_t num) ...@@ -90,7 +89,7 @@ create_alloc_pool (const char *name, size_t size, size_t num)
size = sizeof (alloc_pool_list); size = sizeof (alloc_pool_list);
/* Now align the size to a multiple of 4. */ /* Now align the size to a multiple of 4. */
size = align_four (size); size = align_eight (size);
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
/* Add the aligned size of ID. */ /* Add the aligned size of ID. */
...@@ -154,6 +153,9 @@ free_alloc_pool (alloc_pool pool) ...@@ -154,6 +153,9 @@ free_alloc_pool (alloc_pool pool)
} }
/* Lastly, free the pool and the name. */ /* Lastly, free the pool and the name. */
free (pool->name); free (pool->name);
#ifdef ENABLE_CHECKING
memset (pool, 0xaf, sizeof (*pool));
#endif
free (pool); free (pool);
} }
...@@ -225,6 +227,8 @@ pool_free (alloc_pool pool, void *ptr) ...@@ -225,6 +227,8 @@ pool_free (alloc_pool pool, void *ptr)
if (!ptr) if (!ptr)
abort (); abort ();
memset (ptr, 0xaf, pool->elt_size - offsetof (allocation_object, u.data));
/* Check whether the PTR was allocated from POOL. */ /* Check whether the PTR was allocated from POOL. */
if (pool->id != ALLOCATION_OBJECT_PTR_FROM_USER_PTR (ptr)->id) if (pool->id != ALLOCATION_OBJECT_PTR_FROM_USER_PTR (ptr)->id)
abort (); abort ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment