From 1a81e38b17144624415d252a521fd5a06079d681 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 11 Jan 2011 13:01:13 -0500 Subject: make new code like old code Variable declarations at top of function, separate from initialization. Use == 0 instead of ! for checking pointers. Consistent spacing around {, *, casts. Declare 0-parameter functions as (void) not (). Integer valued functions return -1 on failure, 0 on success. --- umalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'umalloc.c') diff --git a/umalloc.c b/umalloc.c index 4984591..a7e7d2c 100644 --- a/umalloc.c +++ b/umalloc.c @@ -26,7 +26,7 @@ free(void *ap) { Header *bp, *p; - bp = (Header*) ap - 1; + bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; @@ -52,7 +52,7 @@ morecore(uint nu) if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); - if(p == (char*) -1) + if(p == (char*)-1) return 0; hp = (Header*)p; hp->s.size = nu; @@ -81,7 +81,7 @@ malloc(uint nbytes) p->s.size = nunits; } freep = prevp; - return (void*) (p + 1); + return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) -- cgit v1.2.3