From 5fe4dce87abcaf489b618a85253a376bc2531319 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 12 May 2011 12:03:41 +0000 Subject: Avoid fp computations for stats, this make calling malloc_dump() safe in more cases. --- lib/libc/stdlib/malloc.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index eed71c25b69..b803501d41f 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.133 2011/05/12 09:35:37 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.134 2011/05/12 12:03:40 otto Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek * @@ -1571,15 +1571,14 @@ malloc_dump1(int fd, struct dir_info *d) write(fd, buf, strlen(buf)); if (d == NULL) return; - snprintf(buf, sizeof(buf), "Regions slots %zu\n", d->regions_total); + snprintf(buf, sizeof(buf), "Region slots free %zu/%zu\n", + d->regions_free, d->regions_total); write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "Finds %zu/%zu %f\n", d->finds, - d->find_collisions, - 1.0 + (double)d->find_collisions / d->finds); + snprintf(buf, sizeof(buf), "Finds %zu/%zu\n", d->finds, + d->find_collisions); write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "Inserts %zu/%zu %f\n", d->inserts, - d->insert_collisions, - 1.0 + (double)d->insert_collisions / d->inserts); + snprintf(buf, sizeof(buf), "Inserts %zu/%zu\n", d->inserts, + d->insert_collisions); write(fd, buf, strlen(buf)); snprintf(buf, sizeof(buf), "Deletes %zu/%zu\n", d->deletes, d->delete_moves); @@ -1587,8 +1586,6 @@ malloc_dump1(int fd, struct dir_info *d) snprintf(buf, sizeof(buf), "Cheap reallocs %zu/%zu\n", d->cheap_reallocs, d->cheap_realloc_tries); write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "Regions slots free %zu\n", d->regions_free); - write(fd, buf, strlen(buf)); dump_free_chunk_info(fd, d); dump_free_page_info(fd, d); snprintf(buf, sizeof(buf), -- cgit v1.2.3