diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 94db62c585..b7890a91c0 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.20 1997/01/05 22:12:48 tholo Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.21 1997/02/09 22:55:38 tholo Exp $"; |
| 12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
| 13 | 13 | ||
| 14 | /* | 14 | /* |
| @@ -84,7 +84,7 @@ struct pginfo { | |||
| 84 | u_short shift; /* How far to shift for this size chunks */ | 84 | u_short shift; /* How far to shift for this size chunks */ |
| 85 | u_short free; /* How many free chunks */ | 85 | u_short free; /* How many free chunks */ |
| 86 | u_short total; /* How many chunk */ | 86 | u_short total; /* How many chunk */ |
| 87 | u_int bits[1]; /* Which chunks are free */ | 87 | u_long bits[1]; /* Which chunks are free */ |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | /* | 90 | /* |
| @@ -100,10 +100,10 @@ struct pgfree { | |||
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | /* | 102 | /* |
| 103 | * How many bits per u_int in the bitmap. | 103 | * How many bits per u_long in the bitmap. |
| 104 | * Change only if not 8 bits/byte | 104 | * Change only if not 8 bits/byte |
| 105 | */ | 105 | */ |
| 106 | #define MALLOC_BITS (8*sizeof(u_int)) | 106 | #define MALLOC_BITS (8*sizeof(u_long)) |
| 107 | 107 | ||
| 108 | /* | 108 | /* |
| 109 | * Magic values to put in the page_directory | 109 | * Magic values to put in the page_directory |
| @@ -127,11 +127,11 @@ struct pgfree { | |||
| 127 | #endif | 127 | #endif |
| 128 | 128 | ||
| 129 | #if !defined(malloc_pagesize) | 129 | #if !defined(malloc_pagesize) |
| 130 | #define malloc_pagesize (1U<<malloc_pageshift) | 130 | #define malloc_pagesize (1UL<<malloc_pageshift) |
| 131 | #endif | 131 | #endif |
| 132 | 132 | ||
| 133 | #if ((1<<malloc_pageshift) != malloc_pagesize) | 133 | #if ((1UL<<malloc_pageshift) != malloc_pagesize) |
| 134 | #error "(1<<malloc_pageshift) != malloc_pagesize" | 134 | #error "(1UL<<malloc_pageshift) != malloc_pagesize" |
| 135 | #endif | 135 | #endif |
| 136 | 136 | ||
| 137 | #ifndef malloc_maxsize | 137 | #ifndef malloc_maxsize |
| @@ -437,7 +437,7 @@ malloc_init () | |||
| 437 | p = b; | 437 | p = b; |
| 438 | } else if (i == 1 && issetugid() == 0) { | 438 | } else if (i == 1 && issetugid() == 0) { |
| 439 | p = getenv("MALLOC_OPTIONS"); | 439 | p = getenv("MALLOC_OPTIONS"); |
| 440 | } else { | 440 | } else if (i == 2) { |
| 441 | p = malloc_options; | 441 | p = malloc_options; |
| 442 | } | 442 | } |
| 443 | for (; p && *p; p++) { | 443 | for (; p && *p; p++) { |
| @@ -650,15 +650,15 @@ malloc_make_chunks(bits) | |||
| 650 | 650 | ||
| 651 | /* Do a bunch at a time */ | 651 | /* Do a bunch at a time */ |
| 652 | for(;k-i >= MALLOC_BITS; i += MALLOC_BITS) | 652 | for(;k-i >= MALLOC_BITS; i += MALLOC_BITS) |
| 653 | bp->bits[i / MALLOC_BITS] = (u_long)~0; | 653 | bp->bits[i / MALLOC_BITS] = ~0UL; |
| 654 | 654 | ||
| 655 | for(; i < k; i++) | 655 | for(; i < k; i++) |
| 656 | bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS); | 656 | bp->bits[i/MALLOC_BITS] |= 1UL<<(i%MALLOC_BITS); |
| 657 | 657 | ||
| 658 | if (bp == bp->page) { | 658 | if (bp == bp->page) { |
| 659 | /* Mark the ones we stole for ourselves */ | 659 | /* Mark the ones we stole for ourselves */ |
| 660 | for(i=0;l > 0;i++) { | 660 | for(i=0;l > 0;i++) { |
| 661 | bp->bits[i/MALLOC_BITS] &= ~(1<<(i%MALLOC_BITS)); | 661 | bp->bits[i/MALLOC_BITS] &= ~(1UL<<(i%MALLOC_BITS)); |
| 662 | bp->free--; | 662 | bp->free--; |
| 663 | bp->total--; | 663 | bp->total--; |
| 664 | l -= (1 << bits); | 664 | l -= (1 << bits); |
| @@ -685,10 +685,10 @@ malloc_bytes(size) | |||
| 685 | size_t size; | 685 | size_t size; |
| 686 | { | 686 | { |
| 687 | int i,j; | 687 | int i,j; |
| 688 | u_int u; | 688 | u_long u; |
| 689 | struct pginfo *bp; | 689 | struct pginfo *bp; |
| 690 | int k; | 690 | int k; |
| 691 | u_int *lp; | 691 | u_long *lp; |
| 692 | 692 | ||
| 693 | /* Don't bother with anything less than this */ | 693 | /* Don't bother with anything less than this */ |
| 694 | if (size < malloc_minsize) | 694 | if (size < malloc_minsize) |
| @@ -835,7 +835,7 @@ irealloc(ptr, size) | |||
| 835 | i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift; | 835 | i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift; |
| 836 | 836 | ||
| 837 | /* Verify that it isn't a free chunk already */ | 837 | /* Verify that it isn't a free chunk already */ |
| 838 | if ((*mp)->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) { | 838 | if ((*mp)->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) { |
| 839 | wrtwarning("chunk is already free.\n"); | 839 | wrtwarning("chunk is already free.\n"); |
| 840 | return 0; | 840 | return 0; |
| 841 | } | 841 | } |
| @@ -1025,7 +1025,7 @@ free_bytes(ptr, index, info) | |||
| 1025 | return; | 1025 | return; |
| 1026 | } | 1026 | } |
| 1027 | 1027 | ||
| 1028 | if (info->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) { | 1028 | if (info->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) { |
| 1029 | wrtwarning("chunk is already free.\n"); | 1029 | wrtwarning("chunk is already free.\n"); |
| 1030 | return; | 1030 | return; |
| 1031 | } | 1031 | } |
| @@ -1033,7 +1033,7 @@ free_bytes(ptr, index, info) | |||
| 1033 | if (malloc_junk) | 1033 | if (malloc_junk) |
| 1034 | memset(ptr, SOME_JUNK, info->size); | 1034 | memset(ptr, SOME_JUNK, info->size); |
| 1035 | 1035 | ||
| 1036 | info->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS); | 1036 | info->bits[i/MALLOC_BITS] |= 1UL<<(i%MALLOC_BITS); |
| 1037 | info->free++; | 1037 | info->free++; |
| 1038 | 1038 | ||
| 1039 | mp = page_dir + info->shift; | 1039 | mp = page_dir + info->shift; |
