summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-05-17 15:28:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-05-17 15:28:52 +0000
commit577c40800929cb98ea2af18979594ae9867212e8 (patch)
treefddec054b7541ccde4b367f752ece0d7a022300b /cpukit
parentAdded C++ linking rule from Rosimildo DaSilva <rdasilva@connecttel.com>. (diff)
downloadrtems-577c40800929cb98ea2af18979594ae9867212e8.tar.bz2
Patch from D. V. Henkel-Wallace <gumby@zembu.com>:
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.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/rtems/src/region.c16
1 files changed, 16 insertions, 0 deletions
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 <string.h>
+#endif
+
#include <rtems/system.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/support.h>
@@ -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 );