1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-05 19:35:52 +03:00

Fix malloc_info without prioor allocations.

This commit is contained in:
Ulrich Drepper
2010-01-14 13:32:58 -08:00
parent 52e2ea9a83
commit 346bc35c33
2 changed files with 28 additions and 17 deletions

View File

@@ -1,5 +1,9 @@
2010-01-14 Ulrich Drepper <drepper@redhat.com>
[BZ #11126]
* malloc/malloc.c (malloc_info): Initialize malloc if not already
done. Handle empty bin lists.
* posix/unistd.h: Change getpagesize and getdtablesize declaration
visibility some more.

View File

@@ -6369,6 +6369,8 @@ malloc_info (int options, FILE *fp)
mbinptr bin = bin_at (ar_ptr, 1);
struct malloc_chunk *r = bin->fd;
if (r != NULL)
{
while (r != bin)
{
++sizes[NFASTBINS].count;
@@ -6379,6 +6381,7 @@ malloc_info (int options, FILE *fp)
}
nblocks += sizes[NFASTBINS].count;
avail += sizes[NFASTBINS].total;
}
for (size_t i = 2; i < NBINS; ++i)
{
@@ -6388,12 +6391,13 @@ malloc_info (int options, FILE *fp)
sizes[NFASTBINS - 1 + i].to = sizes[NFASTBINS - 1 + i].total
= sizes[NFASTBINS - 1 + i].count = 0;
if (r != NULL)
while (r != bin)
{
++sizes[NFASTBINS - 1 + i].count;
sizes[NFASTBINS - 1 + i].total += r->size;
sizes[NFASTBINS - 1 + i].from = MIN (sizes[NFASTBINS - 1 + i].from,
r->size);
sizes[NFASTBINS - 1 + i].from
= MIN (sizes[NFASTBINS - 1 + i].from, r->size);
sizes[NFASTBINS - 1 + i].to = MAX (sizes[NFASTBINS - 1 + i].to,
r->size);
@@ -6460,6 +6464,9 @@ malloc_info (int options, FILE *fp)
fputs ("</heap>\n", fp);
}
if(__malloc_initialized < 0)
ptmalloc_init ();
fputs ("<malloc version=\"1\">\n", fp);
/* Iterate over all arenas currently in use. */