source: rtems/cpukit/libcsupport/src/free.c @ bd5984de

4.104.11
Last change on this file since bd5984de was bd5984de, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 17, 2008 at 6:37:55 PM

2008-09-17 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/free.c, libcsupport/src/malloc.c, libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_p.h, libcsupport/src/malloc_sbrk_helpers.c, libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/malloc_walk.c, libcsupport/src/mallocfreespace.c, libcsupport/src/mallocinfo.c, libcsupport/src/realloc.c, libcsupport/src/rtems_memalign.c, sapi/include/confdefs.h, score/inline/rtems/score/thread.inl: Add support for optionally having a unified work area. In other words, the RTEMS Workspace and C Program Heap are the same pool of memory.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  calloc()
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#ifdef RTEMS_NEWLIB
19#include "malloc_p.h"
20#include <stdlib.h>
21
22void free(
23  void *ptr
24)
25{
26  MSBUMP(free_calls, 1);
27
28  if ( !ptr )
29    return;
30
31  #if defined(RTEMS_HEAP_DEBUG)
32    _Protected_heap_Walk( RTEMS_Malloc_Heap, 0, false );
33  #endif
34
35  /*
36   *  Do not attempt to free memory if in a critical section or ISR.
37   */
38
39  if ( _System_state_Is_up(_System_state_Get()) && 
40       !malloc_is_system_state_OK() ) {
41      malloc_deferred_free(ptr);
42      return;
43  }
44
45  #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
46    /*
47     *  If configured, check the boundary area
48     */
49    if ( rtems_malloc_boundary_helpers )
50      (*rtems_malloc_boundary_helpers->at_free)(ptr);
51  #endif
52
53  /*
54   *  If configured, update the statistics
55   */
56  if ( rtems_malloc_statistics_helpers )
57    (*rtems_malloc_statistics_helpers->at_free)(ptr);
58
59  if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) {
60    printk( "Program heap: free of bad pointer %p -- range %p - %p \n",
61      ptr,
62      RTEMS_Malloc_Heap->start,
63      RTEMS_Malloc_Heap->end
64    );
65  }
66
67}
68#endif
Note: See TracBrowser for help on using the repository browser.