00001 /* @(#)root/clib:$Id: mmstats.c 20882 2007-11-19 11:31:26Z rdm $ */ 00002 /* Author: */ 00003 00004 /* Access the statistics maintained by `mmalloc'. 00005 Copyright 1990, 1991, 1992 Free Software Foundation 00006 00007 Written May 1989 by Mike Haertel. 00008 Modified Mar 1992 by Fred Fish. (fnf@cygnus.com) 00009 00010 The GNU C Library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Library General Public License as 00012 published by the Free Software Foundation; either version 2 of the 00013 License, or (at your option) any later version. 00014 00015 The GNU C Library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public 00021 License along with the GNU C Library; see the file COPYING.LIB. If 00022 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00023 Boston, MA 02111-1307, USA. 00024 00025 The author may be reached (Email) at the address mike@ai.mit.edu, 00026 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 00027 00028 #include "mmprivate.h" 00029 00030 /* FIXME: See the comment in mmprivate.h where struct mstats is defined. 00031 None of the internal mmalloc structures should be externally visible 00032 outside the library. */ 00033 00034 struct mstats 00035 mmstats (md) 00036 PTR md; 00037 { 00038 struct mstats result; 00039 struct mdesc *mdp; 00040 00041 mdp = MD_TO_MDP (md); 00042 result.bytes_total = 00043 (char *) mdp -> morecore (mdp, 0) - mdp -> heapbase; 00044 result.chunks_used = mdp -> heapstats.chunks_used; 00045 result.bytes_used = mdp -> heapstats.bytes_used; 00046 result.chunks_free = mdp -> heapstats.chunks_free; 00047 result.bytes_free = mdp -> heapstats.bytes_free; 00048 return (result); 00049 }