summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-02-02 18:52:27 -0800
committerLarry Wall <lwall@sems.com>1996-02-02 18:52:27 -0800
commitc07a80fdfe3926b5eb0585b674aa5d1f57b32ade (patch)
tree6d56135571eb9ea6635748469bdaf72ad481247a /malloc.c
parent91b7def858c29dac014df40946a128c06b3aa2ed (diff)
downloadperl-c07a80fdfe3926b5eb0585b674aa5d1f57b32ade.tar.gz
perl5.002beta3
[editor's note: no patch file was found for this release, so no fine-grained changes] I can't find the password for our ftp server, so I had to drop it into ftp://ftp.sems.com/pub/incoming/perl5.002b3.tar.gz, which is a drop directory you can't ls. The current plan is that Andy is gonna whack on this a little more, and then release a gamma in a few days when he's happy with it. So don't get carried away. This is now *late* beta. In other words, have less than the appropriate amount of fun. :-) Larry
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/malloc.c b/malloc.c
index 6e664fc39b..581cbd3755 100644
--- a/malloc.c
+++ b/malloc.c
@@ -78,7 +78,7 @@ static int findbucket _((union overhead *freep, int srchlen));
static union overhead *nextf[NBUCKETS];
extern char *sbrk();
-#ifdef MSTATS
+#ifdef DEBUGGING_MSTATS
/*
* nmalloc[i] is the difference between the number of mallocs and frees
* for a given block size.
@@ -169,7 +169,7 @@ malloc(nbytes)
nextf[bucket] = p->ov_next;
p->ov_magic = MAGIC;
p->ov_index= bucket;
-#ifdef MSTATS
+#ifdef DEBUGGING_MSTATS
nmalloc[bucket]++;
#endif
#ifdef RCHECK
@@ -291,7 +291,7 @@ free(mp)
size = op->ov_index;
op->ov_next = nextf[size];
nextf[size] = op;
-#ifdef MSTATS
+#ifdef DEBUGGING_MSTATS
nmalloc[size]--;
#endif
}
@@ -429,7 +429,7 @@ findbucket(freep, srchlen)
return (-1);
}
-#ifdef MSTATS
+#ifdef DEBUGGING_MSTATS
/*
* mstats - print out statistics about malloc
*
@@ -438,28 +438,41 @@ findbucket(freep, srchlen)
* frees for each size category.
*/
void
-mstats(s)
+dump_mstats(s)
char *s;
{
register int i, j;
register union overhead *p;
- int totfree = 0,
- totused = 0;
+ int topbucket=0, totfree=0, totused=0;
+ u_int nfree[NBUCKETS];
- fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s);
- for (i = 0; i < NBUCKETS; i++) {
+ for (i=0; i < NBUCKETS; i++) {
for (j = 0, p = nextf[i]; p; p = p->ov_next, j++)
;
- fprintf(stderr, " %d", j);
- totfree += j * (1 << (i + 3));
- }
- fprintf(stderr, "\nused:\t");
- for (i = 0; i < NBUCKETS; i++) {
- fprintf(stderr, " %d", nmalloc[i]);
+ nfree[i] = j;
+ totfree += nfree[i] * (1 << (i + 3));
totused += nmalloc[i] * (1 << (i + 3));
+ if (nfree[i] || nmalloc[i])
+ topbucket = i;
+ }
+ if (s)
+ fprintf(stderr, "Memory allocation statistics %s (buckets 8..%d)\n",
+ s, (1 << (topbucket + 3)) );
+ fprintf(stderr, " %7d free: ", totfree);
+ for (i=0; i <= topbucket; i++) {
+ fprintf(stderr, (i<5)?" %5d":" %3d", nfree[i]);
}
- fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n",
- totused, totfree);
+ fprintf(stderr, "\n %7d used: ", totused);
+ for (i=0; i <= topbucket; i++) {
+ fprintf(stderr, (i<5)?" %5d":" %3d", nmalloc[i]);
+ }
+ fprintf(stderr, "\n");
+}
+#else
+void
+dump_mstats(s)
+ char *s;
+{
}
#endif
#endif /* lint */