2008-01-09 Joel Sherrill <joel.sherrill@oarcorp.com>

* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
	libcsupport/src/free.c, libcsupport/src/malloc.c,
	libcsupport/src/malloc_deferred.c,
	libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_p.h,
	libcsupport/src/malloc_sbrk_helpers.c,
	libcsupport/src/posix_memalign.c: Place all deferred free code and
	place it in subroutines. Add plugin for dirtying allocated memory to
	assist in debugging. Clean up comments and spacing as needed.
	* libcsupport/src/malloc_dirtier.c: New file.
This commit is contained in:
Joel Sherrill
2008-01-09 21:08:36 +00:00
parent b9e23917f0
commit 635865aefd
9 changed files with 60 additions and 20 deletions
+12
View File
@@ -1,3 +1,15 @@
2008-01-09 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
libcsupport/src/free.c, libcsupport/src/malloc.c,
libcsupport/src/malloc_deferred.c,
libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_p.h,
libcsupport/src/malloc_sbrk_helpers.c,
libcsupport/src/posix_memalign.c: Place all deferred free code and
place it in subroutines. Add plugin for dirtying allocated memory to
assist in debugging. Clean up comments and spacing as needed.
* libcsupport/src/malloc_dirtier.c: New file.
2008-01-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/objectgetnoprotection.c: Eliminate duplicate exit path code
+1 -1
View File
@@ -38,7 +38,7 @@ void free(
if ( _System_state_Is_up(_System_state_Get()) &&
!malloc_is_system_state_OK() ) {
malloc_defer_free(ptr);
malloc_deferred_free(ptr);
return;
}
+3 -5
View File
@@ -27,14 +27,13 @@ void *malloc(
)
{
void *return_this;
Chain_Node *to_be_freed;
MSBUMP(malloc_calls, 1);
/*
* If some free's have been deferred, then do them now.
*/
malloc_process_deferred_frees();
malloc_deferred_frees_process();
/*
* Validate the parameters
@@ -85,9 +84,8 @@ void *malloc(
/*
* If the user wants us to dirty the allocated memory, then do it.
*/
#ifdef MALLOC_DIRTY
(void) memset(return_this, 0xCF, size);
#endif
if ( rtems_malloc_dirty_helper )
(*rtems_malloc_dirty_helper)( return_this, size );
/*
* If configured, update the statistics
+9 -2
View File
@@ -22,6 +22,8 @@
#include "malloc_p.h"
Chain_Control RTEMS_Malloc_GC_list;
boolean malloc_is_system_state_OK(void)
{
if ( _Thread_Dispatch_disable_level > 0 )
@@ -33,7 +35,12 @@ boolean malloc_is_system_state_OK(void)
return TRUE;
}
void malloc_process_deferred_frees(void)
void malloc_deferred_frees_initialize(void)
{
Chain_Initialize_empty(&RTEMS_Malloc_GC_list);
}
void malloc_deferred_frees_process(void)
{
Chain_Node *to_be_freed;
@@ -44,7 +51,7 @@ void malloc_process_deferred_frees(void)
free(to_be_freed);
}
void malloc_defer_free(
void malloc_deferred_free(
void *pointer
)
{
+30
View File
@@ -0,0 +1,30 @@
/*
* RTEMS Malloc Family -- Dirty Memory from Malloc
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
#include <rtems/malloc.h>
#include "malloc_p.h"
#include <errno.h>
void rtems_malloc_dirty_memory(
void *start,
size_t size
)
{
(void) memset(start, 0xCF, size);
}
+1 -2
View File
@@ -21,7 +21,6 @@
#include "malloc_p.h"
Heap_Control RTEMS_Malloc_Heap;
Chain_Control RTEMS_Malloc_GC_list;
rtems_malloc_statistics_t rtems_malloc_statistics;
void RTEMS_Malloc_Initialize(
@@ -50,7 +49,7 @@ void RTEMS_Malloc_Initialize(
/*
* Initialize the garbage collection list to start with nothing on it.
*/
Chain_Initialize_empty(&RTEMS_Malloc_GC_list);
malloc_deferred_frees_initialize();
starting_address = start;
+2 -7
View File
@@ -38,7 +38,6 @@
* Basic management data
*/
extern Heap_Control RTEMS_Malloc_Heap;
extern Chain_Control RTEMS_Malloc_GC_list;
/*
* Malloc Statistics Structure
@@ -47,14 +46,10 @@ extern rtems_malloc_statistics_t rtems_malloc_statistics;
#define MSBUMP(_f,_n) rtems_malloc_statistics._f += (_n)
/*
* Dirty memory plugin
*/
#define MALLOC_DIRTY
/*
* Process deferred free operations
*/
boolean malloc_is_system_state_OK(void);
void malloc_process_deferred_frees(void);
void malloc_deferred_frees_initialize(void);
void malloc_deferred_frees_process(void);
void malloc_defer_free(void *);
+1 -2
View File
@@ -1,6 +1,5 @@
/*
* RTEMS Malloc Family Implementation --Initialization
*
* RTEMS Malloc -- SBRK Support Plugin
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
+1 -1
View File
@@ -59,7 +59,7 @@ int posix_memalign(
*
* If some free's have been deferred, then do them now.
*/
malloc_process_deferred_frees();
malloc_deferred_frees_process();
#if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
/*