diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 9f7ceba080..e3405df39a 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.73 2005/05/24 16:39:05 tedu Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.74 2005/06/07 04:42:42 tedu Exp $"; |
| 12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
| 13 | 13 | ||
| 14 | /* | 14 | /* |
| @@ -211,6 +211,8 @@ static int malloc_freeprot; | |||
| 211 | 211 | ||
| 212 | /* use guard pages after allocations? */ | 212 | /* use guard pages after allocations? */ |
| 213 | static int malloc_guard = 0; | 213 | static int malloc_guard = 0; |
| 214 | /* align pointers to end of page? */ | ||
| 215 | static int malloc_ptrguard; | ||
| 214 | 216 | ||
| 215 | #if defined(__FreeBSD__) || (defined(__OpenBSD__) && defined(MADV_FREE)) | 217 | #if defined(__FreeBSD__) || (defined(__OpenBSD__) && defined(MADV_FREE)) |
| 216 | /* pass the kernel a hint on free pages ? */ | 218 | /* pass the kernel a hint on free pages ? */ |
| @@ -612,6 +614,8 @@ malloc_init(void) | |||
| 612 | case 'J': malloc_junk = 1; break; | 614 | case 'J': malloc_junk = 1; break; |
| 613 | case 'n': malloc_silent = 0; break; | 615 | case 'n': malloc_silent = 0; break; |
| 614 | case 'N': malloc_silent = 1; break; | 616 | case 'N': malloc_silent = 1; break; |
| 617 | case 'p': malloc_ptrguard = 0; break; | ||
| 618 | case 'P': malloc_ptrguard = 1; break; | ||
| 615 | case 'r': malloc_realloc = 0; break; | 619 | case 'r': malloc_realloc = 0; break; |
| 616 | case 'R': malloc_realloc = 1; break; | 620 | case 'R': malloc_realloc = 1; break; |
| 617 | #ifdef __FreeBSD__ | 621 | #ifdef __FreeBSD__ |
| @@ -1082,7 +1086,7 @@ imalloc(size_t size) | |||
| 1082 | if (suicide) | 1086 | if (suicide) |
| 1083 | abort(); | 1087 | abort(); |
| 1084 | 1088 | ||
| 1085 | if (malloc_guard && size == PTR_SIZE) { | 1089 | if (malloc_ptrguard && size == PTR_SIZE) { |
| 1086 | ptralloc = 1; | 1090 | ptralloc = 1; |
| 1087 | size = malloc_pagesize; | 1091 | size = malloc_pagesize; |
| 1088 | } | 1092 | } |
| @@ -1128,7 +1132,7 @@ irealloc(void *ptr, size_t size) | |||
| 1128 | return (NULL); | 1132 | return (NULL); |
| 1129 | } | 1133 | } |
| 1130 | 1134 | ||
| 1131 | if (malloc_guard && PTR_ALIGNED(ptr)) { | 1135 | if (malloc_ptrguard && PTR_ALIGNED(ptr)) { |
| 1132 | if (size <= PTR_SIZE) | 1136 | if (size <= PTR_SIZE) |
| 1133 | return (ptr); | 1137 | return (ptr); |
| 1134 | else { | 1138 | else { |
| @@ -1602,7 +1606,7 @@ ifree(void *ptr) | |||
| 1602 | if (suicide) | 1606 | if (suicide) |
| 1603 | return; | 1607 | return; |
| 1604 | 1608 | ||
| 1605 | if (malloc_guard && PTR_ALIGNED(ptr)) | 1609 | if (malloc_ptrguard && PTR_ALIGNED(ptr)) |
| 1606 | ptr = (char *)ptr - PTR_GAP; | 1610 | ptr = (char *)ptr - PTR_GAP; |
| 1607 | 1611 | ||
| 1608 | index = ptr2index(ptr); | 1612 | index = ptr2index(ptr); |
