diff options
author | deraadt <> | 2005-06-17 21:38:59 +0000 |
---|---|---|
committer | deraadt <> | 2005-06-17 21:38:59 +0000 |
commit | 3e3bbc8803c3a00472c2fb46d7b835b74ce7b7dc (patch) | |
tree | b873414180dfe124ad8d89bc64888701afe05f50 /src | |
parent | a92e3b95173517780038be86107a02ae3c711085 (diff) | |
download | openbsd-3e3bbc8803c3a00472c2fb46d7b835b74ce7b7dc.tar.gz openbsd-3e3bbc8803c3a00472c2fb46d7b835b74ce7b7dc.tar.bz2 openbsd-3e3bbc8803c3a00472c2fb46d7b835b74ce7b7dc.zip |
no longer a need for the free(malloc(1)) hack, because the brk stuff
no longer needs initializing (we use mmap for malloc entirely now)
noticed by kjell, ok dhartmei, tested by me
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/atexit.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index 4fd2c57318..0bffc05344 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c | |||
@@ -29,7 +29,7 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #if defined(LIBC_SCCS) && !defined(lint) | 31 | #if defined(LIBC_SCCS) && !defined(lint) |
32 | static char *rcsid = "$OpenBSD: atexit.c,v 1.8 2005/03/30 18:51:49 pat Exp $"; | 32 | static char *rcsid = "$OpenBSD: atexit.c,v 1.9 2005/06/17 21:38:59 deraadt Exp $"; |
33 | #endif /* LIBC_SCCS and not lint */ | 33 | #endif /* LIBC_SCCS and not lint */ |
34 | 34 | ||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
@@ -73,10 +73,6 @@ atexit(void (*fn)(void)) | |||
73 | return (-1); | 73 | return (-1); |
74 | } | 74 | } |
75 | if (p == NULL) { | 75 | if (p == NULL) { |
76 | if (__atexit_invalid) { | ||
77 | free(malloc(1)); | ||
78 | __atexit_invalid = 0; | ||
79 | } | ||
80 | p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, | 76 | p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, |
81 | MAP_ANON | MAP_PRIVATE, -1, 0); | 77 | MAP_ANON | MAP_PRIVATE, -1, 0); |
82 | if (p == MAP_FAILED) | 78 | if (p == MAP_FAILED) |
@@ -90,6 +86,8 @@ atexit(void (*fn)(void)) | |||
90 | sizeof(p->fns[0]); | 86 | sizeof(p->fns[0]); |
91 | p->next = __atexit; | 87 | p->next = __atexit; |
92 | __atexit = p; | 88 | __atexit = p; |
89 | if (__atexit_invalid) | ||
90 | __atexit_invalid = 0; | ||
93 | } | 91 | } |
94 | p->fns[p->ind++] = fn; | 92 | p->fns[p->ind++] = fn; |
95 | if (mprotect(p, pgsize, PROT_READ)) | 93 | if (mprotect(p, pgsize, PROT_READ)) |
@@ -111,10 +109,6 @@ __atexit_register_cleanup(void (*fn)(void)) | |||
111 | while (p != NULL && p->next != NULL) | 109 | while (p != NULL && p->next != NULL) |
112 | p = p->next; | 110 | p = p->next; |
113 | if (p == NULL) { | 111 | if (p == NULL) { |
114 | if (__atexit_invalid) { | ||
115 | free(malloc(1)); | ||
116 | __atexit_invalid = 0; | ||
117 | } | ||
118 | p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, | 112 | p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, |
119 | MAP_ANON | MAP_PRIVATE, -1, 0); | 113 | MAP_ANON | MAP_PRIVATE, -1, 0); |
120 | if (p == MAP_FAILED) | 114 | if (p == MAP_FAILED) |
@@ -124,6 +118,8 @@ __atexit_register_cleanup(void (*fn)(void)) | |||
124 | sizeof(p->fns[0]); | 118 | sizeof(p->fns[0]); |
125 | p->next = NULL; | 119 | p->next = NULL; |
126 | __atexit = p; | 120 | __atexit = p; |
121 | if (__atexit_invalid) | ||
122 | __atexit_invalid = 0; | ||
127 | } else { | 123 | } else { |
128 | if (mprotect(p, pgsize, PROT_READ | PROT_WRITE)) | 124 | if (mprotect(p, pgsize, PROT_READ | PROT_WRITE)) |
129 | return; | 125 | return; |