diff options
author | 2003-08-11 06:23:07 +0000 | |
---|---|---|
committer | 2003-08-11 06:23:07 +0000 | |
commit | 599546b3df9d501c5df00d16afc0d6ef8054a751 (patch) | |
tree | 497dafb2e950a5b91385da061a8c32b00de30455 /sys/lib/libsa/alloc.c | |
parent | make sure Debugger() is called only inside _both_ DDB and OSIOP_DEBUG (diff) | |
download | wireguard-openbsd-599546b3df9d501c5df00d16afc0d6ef8054a751.tar.xz wireguard-openbsd-599546b3df9d501c5df00d16afc0d6ef8054a751.zip |
ansification and knf and protos
Diffstat (limited to 'sys/lib/libsa/alloc.c')
-rw-r--r-- | sys/lib/libsa/alloc.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/sys/lib/libsa/alloc.c b/sys/lib/libsa/alloc.c index de916193fda..2f41d683364 100644 --- a/sys/lib/libsa/alloc.c +++ b/sys/lib/libsa/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.8 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: alloc.c,v 1.9 2003/08/11 06:23:09 deraadt Exp $ */ /* $NetBSD: alloc.c,v 1.6 1997/02/04 18:36:33 thorpej Exp $ */ /* @@ -119,10 +119,9 @@ static char *top = end; #endif void * -alloc(size) - unsigned size; +alloc(unsigned int size) { - register struct fl **f = &freelist, **bestf = NULL; + struct fl **f = &freelist, **bestf = NULL; #ifndef ALLOC_FIRST_FIT unsigned bestsize = 0xffffffff; /* greater than any real size */ #endif @@ -147,11 +146,11 @@ alloc(size) if ((*f)->size < bestsize) { /* keep best fit */ - bestf = f; - bestsize = (*f)->size; - } - } - f = &((*f)->next); + bestf = f; + bestsize = (*f)->size; + } + } + f = &((*f)->next); } /* no match in freelist if bestsize unchanged */ @@ -159,11 +158,11 @@ alloc(size) #endif if (failed) { /* nothing found */ - /* + /* * allocate from heap, keep chunk len in * first word */ - help = top; + help = top; /* make _sure_ the region can hold a struct fl. */ if (size < ALIGN(sizeof (struct fl *))) @@ -171,7 +170,7 @@ alloc(size) top += ALIGN(sizeof(unsigned)) + ALIGN(size); #ifdef HEAP_LIMIT if (top > (char *)HEAP_LIMIT) - panic("heap full (0x%lx+%u)", help, size); + panic("heap full (0x%lx+%u)", help, size); #endif *(unsigned *)help = ALIGN(size); #ifdef ALLOC_TRACE @@ -186,8 +185,8 @@ alloc(size) #ifndef ALLOC_FIRST_FIT found: #endif - /* remove from freelist */ - help = (char *)*f; + /* remove from freelist */ + help = (char *)*f; *f = (*f)->next; #ifdef ALLOC_TRACE printf("=%p (origsize %u)\n", help + ALIGN(sizeof(unsigned)), @@ -197,18 +196,17 @@ found: } void -free(ptr, size) - void *ptr; - unsigned size; /* only for consistence check */ +free(void *ptr, unsigned int size) { - register struct fl *f = - (struct fl *)((char *)ptr - ALIGN(sizeof(unsigned))); + struct fl *f = (struct fl *)((char *)ptr - + ALIGN(sizeof(unsigned))); + #ifdef ALLOC_TRACE printf("free(%p, %u) (origsize %u)\n", ptr, size, f->size); #endif #ifdef DEBUG - if (size > f->size) - printf("free %u bytes @%p, should be <=%u\n", + if (size > f->size) + printf("free %u bytes @%p, should be <=%u\n", size, ptr, f->size); #ifdef HEAP_START if (ptr < (void *)HEAP_START) |