source: rtems/cpukit/libcsupport/src/malloc_report_statistics_plugin.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  malloc_report_statistics with plugin Implementation
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
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#ifdef RTEMS_NEWLIB
17#include "malloc_p.h"
18#include "inttypes.h"
19
20void malloc_report_statistics_with_plugin(
21  void                  *context,
22  rtems_printk_plugin_t  print
23)
24{
25  rtems_malloc_statistics_t *s = &rtems_malloc_statistics;
26  uint32_t space_available = s->space_available;
27  uint32_t allocated = (uint32_t) (s->lifetime_allocated - s->lifetime_freed);
28  uint32_t max_depth = s->max_depth;
29    /* avoid float! */
30  uint32_t allocated_per_cent = (allocated * 100) / space_available;
31  uint32_t max_depth_per_cent = (max_depth * 100) / space_available;
32
33  (*print)(
34    context,
35    "Malloc statistics\n"
36    "  avail:%"PRIu32"k  allocated:%"PRIu32"k (%"PRIu32"%%) "
37      "max:%"PRIu32"k (%"PRIu32"%%)"
38      " lifetime:%"PRIuMAX"k freed:%"PRIuMAX"k\n",
39    space_available / 1024,
40    allocated / 1024,
41    allocated_per_cent,
42    max_depth / 1024,
43    max_depth_per_cent,
44    s->lifetime_allocated / 1024,
45    s->lifetime_freed / 1024
46  );
47  (*print)(
48    context,
49    "  Call counts:   malloc:%"PRIu32"   memalign:%"PRIu32"   free:%"PRIu32
50       "   realloc:%"PRIu32"   calloc:%"PRIu32"\n",
51    s->malloc_calls,
52    s->memalign_calls,
53    s->free_calls,
54    s->realloc_calls,
55    s->calloc_calls
56  );
57}
58
59#endif
Note: See TracBrowser for help on using the repository browser.