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

4.115
Last change on this file since e02d5dd9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief calloc()
5 * @ingroup libcsupport
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#ifdef RTEMS_NEWLIB
22#include "malloc_p.h"
23#include <stdlib.h>
24
25#include <rtems/score/sysstate.h>
26
27void free(
28  void *ptr
29)
30{
31  MSBUMP(free_calls, 1);
32
33  if ( !ptr )
34    return;
35
36  /*
37   *  Do not attempt to free memory if in a critical section or ISR.
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  /*
46   *  If configured, update the statistics
47   */
48  if ( rtems_malloc_statistics_helpers )
49    (*rtems_malloc_statistics_helpers->at_free)(ptr);
50
51  if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) {
52    printk( "Program heap: free of bad pointer %p -- range %p - %p \n",
53      ptr,
54      RTEMS_Malloc_Heap->area_begin,
55      RTEMS_Malloc_Heap->area_end
56    );
57  }
58
59}
60#endif
Note: See TracBrowser for help on using the repository browser.