Date: Sat, 16 Apr 2011 10:57:11 +0000 (UTC) From: Bruce Cran <brucec@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r220705 - stable/8/tools/test/malloc Message-ID: <201104161057.p3GAvBQM002375@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: brucec Date: Sat Apr 16 10:57:11 2011 New Revision: 220705 URL: http://svn.freebsd.org/changeset/base/220705 Log: MFC r219511: Fix warnings and style(9) issues. Set WARNS to 6. Modified: stable/8/tools/test/malloc/Makefile stable/8/tools/test/malloc/main.c Directory Properties: stable/8/tools/test/malloc/ (props changed) Modified: stable/8/tools/test/malloc/Makefile ============================================================================== --- stable/8/tools/test/malloc/Makefile Sat Apr 16 10:52:11 2011 (r220704) +++ stable/8/tools/test/malloc/Makefile Sat Apr 16 10:57:11 2011 (r220705) @@ -4,6 +4,7 @@ SRCS= main.c .PATH: ${.CURDIR}/../../../lib/libc/stdlib NO_MAN= +WARNS?=6 test: malloc @echo Modified: stable/8/tools/test/malloc/main.c ============================================================================== --- stable/8/tools/test/malloc/main.c Sat Apr 16 10:52:11 2011 (r220704) +++ stable/8/tools/test/malloc/main.c Sat Apr 16 10:57:11 2011 (r220705) @@ -1,6 +1,7 @@ /* $FreeBSD$ */ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <unistd.h> u_long NBUCKETS = 2000; @@ -12,25 +13,25 @@ char **foo; int main(int argc, char **argv) { - int i,j,k; + u_long i,j,k; if (argc > 1) NOPS = strtoul(argv[1],0,0); if (argc > 2) NBUCKETS = strtoul(argv[2],0,0); if (argc > 3) NSIZE = strtoul(argv[3],0,0); - printf("BRK(0)=%x ",sbrk(0)); - foo = malloc (sizeof *foo * NBUCKETS); - memset(foo,0,sizeof *foo * NBUCKETS); + printf("BRK(0)=%p ", sbrk(0)); + foo = malloc(sizeof(*foo) * NBUCKETS); + memset(foo, 0, sizeof(*foo) * NBUCKETS); for (i = 1; i <= 4096; i *= 2) { - for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) { + for (j = 0; j < 40960/i && j < NBUCKETS; j++) { foo[j] = malloc(i); } - for (j = 0 ; j < 40960/i && j < NBUCKETS; j++) { + for (j = 0; j < 40960/i && j < NBUCKETS; j++) { free(foo[j]); - foo[j] = 0; + foo[j] = NULL; } } - for (i = 0 ; i < NOPS ; i++) { + for (i = 0; i < NOPS; i++) { j = random() % NBUCKETS; k = random() % NSIZE; foo[j] = realloc(foo[j], k & 1 ? 0 : k); @@ -39,19 +40,19 @@ main(int argc, char **argv) * Workaround because realloc return bogus pointer rather than * NULL if passed zero length. */ - foo[j] = 0; + foo[j] = NULL; } if (foo[j]) foo[j][0] = 1; } - printf("BRK(1)=%x ",sbrk(0)); - for (j = 0 ; j < NBUCKETS ; j++) { + printf("BRK(1)=%p ", sbrk(0)); + for (j = 0; j < NBUCKETS; j++) { if (foo[j]) { free(foo[j]); - foo[j] = 0; + foo[j] = NULL; } } - printf("BRK(2)=%x NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n", - sbrk(0),NOPS,NBUCKETS,NSIZE); + printf("BRK(2)=%p NOPS=%lu NBUCKETS=%lu NSIZE=%lu\n", + sbrk(0), NOPS, NBUCKETS, NSIZE); return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104161057.p3GAvBQM002375>