source: rtems/cpukit/libcsupport/src/malloc_statistics_helpers.c @ 7c411bd

4.104.115
Last change on this file since 7c411bd was 7c411bd, checked in by Joel Sherrill <joel.sherrill@…>, on 09/14/09 at 14:48:38

2009-09-14 Sebastian Huber <Sebastian.Huber@…>

  • score/src/wkspace.c: Removed work space area consistency checks.
  • libblock/include/rtems/ide_part_table.h: Functions are now deprecated.
  • libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c, libcsupport/src/malloc_boundary.c, libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_report_statistics_plugin.c, libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, rtems/inline/rtems/rtems/region.inl: Update for heap API changes.

2009-09-14 Christian Mauderer <christian.mauderer@…>

  • libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the pointer to the string is NULL.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1
2/*
3 *  _calloc_r Implementation
4 *
5 *  COPYRIGHT (c) 1989-2007.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#ifdef RTEMS_NEWLIB
20#include "malloc_p.h"
21
22#include <sys/reent.h>
23#include <stdlib.h>
24
25
26static void rtems_malloc_statistics_initialize( void )
27{
28  /*
29   * Zero all the statistics
30   */
31  (void) memset(&rtems_malloc_statistics, 0, sizeof(rtems_malloc_statistics));
32}
33
34static void rtems_malloc_statistics_at_malloc(
35  void *pointer
36)
37{
38  uintptr_t actual_size = 0;
39  uint32_t current_depth;
40  rtems_malloc_statistics_t *s = &rtems_malloc_statistics;
41
42  if ( !pointer )
43    return;
44
45  _Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &actual_size);
46
47  MSBUMP(lifetime_allocated, actual_size);
48
49  current_depth = (uint32_t) (s->lifetime_allocated - s->lifetime_freed);
50  if (current_depth > s->max_depth)
51      s->max_depth = current_depth;
52}
53
54/*
55 *  If the pointer is not in the heap, then we won't be able to get its
56 *  size and thus we skip updating the statistics.
57 */
58static void rtems_malloc_statistics_at_free(
59  void *pointer
60)
61{
62  uintptr_t size;
63
64  if (_Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &size) ) {
65    MSBUMP(lifetime_freed, size);
66  }
67}
68
69rtems_malloc_statistics_functions_t rtems_malloc_statistics_helpers_table = {
70  rtems_malloc_statistics_initialize,
71  rtems_malloc_statistics_at_malloc,
72  rtems_malloc_statistics_at_free,
73};
74
75#endif
Note: See TracBrowser for help on using the repository browser.