diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-06-17 21:39:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-06-17 21:39:00 +0000 |
commit | 971c23e12b10d7d1e5c029afbd6de8b80e50bc98 (patch) | |
tree | f30154dea7e72604f937850b25a1158ca8b1327c /lib/libc | |
parent | b69f31113a8ed5bd63523b0ac817b6a04b36cd56 (diff) |
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 'lib/libc')
-rw-r--r-- | lib/libc/stdlib/atexit.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 4fd2c573186..0bffc05344c 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -29,7 +29,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: atexit.c,v 1.8 2005/03/30 18:51:49 pat Exp $"; +static char *rcsid = "$OpenBSD: atexit.c,v 1.9 2005/06/17 21:38:59 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -73,10 +73,6 @@ atexit(void (*fn)(void)) return (-1); } if (p == NULL) { - if (__atexit_invalid) { - free(malloc(1)); - __atexit_invalid = 0; - } p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (p == MAP_FAILED) @@ -90,6 +86,8 @@ atexit(void (*fn)(void)) sizeof(p->fns[0]); p->next = __atexit; __atexit = p; + if (__atexit_invalid) + __atexit_invalid = 0; } p->fns[p->ind++] = fn; if (mprotect(p, pgsize, PROT_READ)) @@ -111,10 +109,6 @@ __atexit_register_cleanup(void (*fn)(void)) while (p != NULL && p->next != NULL) p = p->next; if (p == NULL) { - if (__atexit_invalid) { - free(malloc(1)); - __atexit_invalid = 0; - } p = mmap(NULL, pgsize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (p == MAP_FAILED) @@ -124,6 +118,8 @@ __atexit_register_cleanup(void (*fn)(void)) sizeof(p->fns[0]); p->next = NULL; __atexit = p; + if (__atexit_invalid) + __atexit_invalid = 0; } else { if (mprotect(p, pgsize, PROT_READ | PROT_WRITE)) return; |