diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 9d73ab021d..85a95652e0 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #if defined(LIBC_SCCS) && !defined(lint) | 10 | #if defined(LIBC_SCCS) && !defined(lint) |
| 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.58 2003/07/19 23:52:27 tdeval Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.59 2003/08/04 16:51:49 jfb Exp $"; |
| 12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
| 13 | 13 | ||
| 14 | /* | 14 | /* |
| @@ -250,8 +250,7 @@ static void *malloc_bytes(size_t size); | |||
| 250 | 250 | ||
| 251 | #ifdef MALLOC_STATS | 251 | #ifdef MALLOC_STATS |
| 252 | void | 252 | void |
| 253 | malloc_dump(fd) | 253 | malloc_dump(FILE *fd) |
| 254 | FILE *fd; | ||
| 255 | { | 254 | { |
| 256 | struct pginfo **pd; | 255 | struct pginfo **pd; |
| 257 | struct pgfree *pf; | 256 | struct pgfree *pf; |
| @@ -310,8 +309,7 @@ malloc_dump(fd) | |||
| 310 | extern char *__progname; | 309 | extern char *__progname; |
| 311 | 310 | ||
| 312 | static void | 311 | static void |
| 313 | wrterror(p) | 312 | wrterror(char *p) |
| 314 | char *p; | ||
| 315 | { | 313 | { |
| 316 | char *q = " error: "; | 314 | char *q = " error: "; |
| 317 | struct iovec iov[4]; | 315 | struct iovec iov[4]; |
| @@ -335,8 +333,7 @@ wrterror(p) | |||
| 335 | } | 333 | } |
| 336 | 334 | ||
| 337 | static void | 335 | static void |
| 338 | wrtwarning(p) | 336 | wrtwarning(char *p) |
| 339 | char *p; | ||
| 340 | { | 337 | { |
| 341 | char *q = " warning: "; | 338 | char *q = " warning: "; |
| 342 | struct iovec iov[4]; | 339 | struct iovec iov[4]; |
| @@ -359,7 +356,7 @@ wrtwarning(p) | |||
| 359 | 356 | ||
| 360 | #ifdef MALLOC_STATS | 357 | #ifdef MALLOC_STATS |
| 361 | static void | 358 | static void |
| 362 | malloc_exit() | 359 | malloc_exit(void) |
| 363 | { | 360 | { |
| 364 | FILE *fd = fopen("malloc.out", "a"); | 361 | FILE *fd = fopen("malloc.out", "a"); |
| 365 | char *q = "malloc() warning: Couldn't dump stats.\n"; | 362 | char *q = "malloc() warning: Couldn't dump stats.\n"; |
| @@ -376,8 +373,7 @@ malloc_exit() | |||
| 376 | * Allocate a number of pages from the OS | 373 | * Allocate a number of pages from the OS |
| 377 | */ | 374 | */ |
| 378 | static void * | 375 | static void * |
| 379 | map_pages(pages) | 376 | map_pages(size_t pages) |
| 380 | size_t pages; | ||
| 381 | { | 377 | { |
| 382 | caddr_t result, tail; | 378 | caddr_t result, tail; |
| 383 | 379 | ||
| @@ -412,8 +408,7 @@ map_pages(pages) | |||
| 412 | * Extend page directory | 408 | * Extend page directory |
| 413 | */ | 409 | */ |
| 414 | static int | 410 | static int |
| 415 | extend_pgdir(index) | 411 | extend_pgdir(u_long index) |
| 416 | u_long index; | ||
| 417 | { | 412 | { |
| 418 | struct pginfo **new, **old; | 413 | struct pginfo **new, **old; |
| 419 | size_t i, oldlen; | 414 | size_t i, oldlen; |
| @@ -466,7 +461,7 @@ extend_pgdir(index) | |||
| 466 | * Initialize the world | 461 | * Initialize the world |
| 467 | */ | 462 | */ |
| 468 | static void | 463 | static void |
| 469 | malloc_init () | 464 | malloc_init(void) |
| 470 | { | 465 | { |
| 471 | char *p, b[64]; | 466 | char *p, b[64]; |
| 472 | int i, j; | 467 | int i, j; |
| @@ -584,8 +579,7 @@ malloc_init () | |||
| 584 | * Allocate a number of complete pages | 579 | * Allocate a number of complete pages |
| 585 | */ | 580 | */ |
| 586 | static void * | 581 | static void * |
| 587 | malloc_pages(size) | 582 | malloc_pages(size_t size) |
| 588 | size_t size; | ||
| 589 | { | 583 | { |
| 590 | void *p, *delay_free = NULL; | 584 | void *p, *delay_free = NULL; |
| 591 | int i; | 585 | int i; |
| @@ -670,8 +664,7 @@ malloc_pages(size) | |||
| 670 | */ | 664 | */ |
| 671 | 665 | ||
| 672 | static __inline__ int | 666 | static __inline__ int |
| 673 | malloc_make_chunks(bits) | 667 | malloc_make_chunks(int bits) |
| 674 | int bits; | ||
| 675 | { | 668 | { |
| 676 | struct pginfo *bp; | 669 | struct pginfo *bp; |
| 677 | void *pp; | 670 | void *pp; |
| @@ -765,8 +758,7 @@ malloc_make_chunks(bits) | |||
| 765 | * Allocate a fragment | 758 | * Allocate a fragment |
| 766 | */ | 759 | */ |
| 767 | static void * | 760 | static void * |
| 768 | malloc_bytes(size) | 761 | malloc_bytes(size_t size) |
| 769 | size_t size; | ||
| 770 | { | 762 | { |
| 771 | int i,j; | 763 | int i,j; |
| 772 | u_long u; | 764 | u_long u; |
| @@ -828,8 +820,7 @@ malloc_bytes(size) | |||
| 828 | * Allocate a piece of memory | 820 | * Allocate a piece of memory |
| 829 | */ | 821 | */ |
| 830 | static void * | 822 | static void * |
| 831 | imalloc(size) | 823 | imalloc(size_t size) |
| 832 | size_t size; | ||
| 833 | { | 824 | { |
| 834 | void *result; | 825 | void *result; |
| 835 | 826 | ||
| @@ -861,9 +852,7 @@ imalloc(size) | |||
| 861 | * Change the size of an allocation. | 852 | * Change the size of an allocation. |
| 862 | */ | 853 | */ |
| 863 | static void * | 854 | static void * |
| 864 | irealloc(ptr, size) | 855 | irealloc(void *ptr, size_t size) |
| 865 | void *ptr; | ||
| 866 | size_t size; | ||
| 867 | { | 856 | { |
| 868 | void *p; | 857 | void *p; |
| 869 | u_long osize, index; | 858 | u_long osize, index; |
| @@ -966,10 +955,7 @@ irealloc(ptr, size) | |||
| 966 | */ | 955 | */ |
| 967 | 956 | ||
| 968 | static __inline__ void | 957 | static __inline__ void |
| 969 | free_pages(ptr, index, info) | 958 | free_pages(void *ptr, int index, struct pginfo *info) |
| 970 | void *ptr; | ||
| 971 | int index; | ||
| 972 | struct pginfo *info; | ||
| 973 | { | 959 | { |
| 974 | int i; | 960 | int i; |
| 975 | struct pgfree *pf, *pt=NULL; | 961 | struct pgfree *pf, *pt=NULL; |
| @@ -1104,10 +1090,7 @@ free_pages(ptr, index, info) | |||
| 1104 | 1090 | ||
| 1105 | /* ARGSUSED */ | 1091 | /* ARGSUSED */ |
| 1106 | static __inline__ void | 1092 | static __inline__ void |
| 1107 | free_bytes(ptr, index, info) | 1093 | free_bytes(void *ptr, int index, struct pginfo *info) |
| 1108 | void *ptr; | ||
| 1109 | int index; | ||
| 1110 | struct pginfo *info; | ||
| 1111 | { | 1094 | { |
| 1112 | int i; | 1095 | int i; |
| 1113 | struct pginfo **mp; | 1096 | struct pginfo **mp; |
| @@ -1178,8 +1161,7 @@ free_bytes(ptr, index, info) | |||
| 1178 | } | 1161 | } |
| 1179 | 1162 | ||
| 1180 | static void | 1163 | static void |
| 1181 | ifree(ptr) | 1164 | ifree(void *ptr) |
| 1182 | void *ptr; | ||
| 1183 | { | 1165 | { |
| 1184 | struct pginfo *info; | 1166 | struct pginfo *info; |
| 1185 | int index; | 1167 | int index; |
