source: rtems/cpukit/libcsupport/src/free.c @ 2f3e2e0

4.104.115
Last change on this file since 2f3e2e0 was 4088d01d, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/01/08 at 11:42:19

Convert using "bool".

  • 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.