From 577c40800929cb98ea2af18979594ae9867212e8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 17 May 1999 15:28:52 +0000 Subject: Patch from D. V. Henkel-Wallace : Here's a tiny patch that shreds memory returned to the pool (such as by free() and delete). This may help people find some nasty bugs, so here it is. --- cpukit/rtems/src/region.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cpukit') diff --git a/cpukit/rtems/src/region.c b/cpukit/rtems/src/region.c index 14467c73da..d7b27132a0 100644 --- a/cpukit/rtems/src/region.c +++ b/cpukit/rtems/src/region.c @@ -13,6 +13,10 @@ * $Id$ */ +#ifdef RTEMS_REGION_FREE_SHRED_PATTERN +#include +#endif + #include #include #include @@ -450,6 +454,9 @@ rtems_status_code rtems_region_return_segment( Thread_Control *the_thread; Objects_Locations location; void **the_segment; +#ifdef RTEMS_SHRED_ON_FREE + unsigned32 size; +#endif int status; the_region = _Region_Get( id, &location ); @@ -465,6 +472,15 @@ rtems_status_code rtems_region_return_segment( _Region_Debug_Walk( the_region, 3 ); +#ifdef RTEMS_REGION_FREE_SHRED_PATTERN + if ( _Heap_Size_of_user_area( &the_region->Memory, segment, size ) ) { + memset(segment, (RTEMS_REGION_FREE_SHRED_BYTE & 0xFF), size); + } else { + _Thread_Enable_dispatch(); + return RTEMS_INVALID_ADDRESS; + } +#endif + status = _Region_Free_segment( the_region, segment ); _Region_Debug_Walk( the_region, 4 ); -- cgit v1.2.3