diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2009-04-23 17:54:22 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2009-04-23 17:54:22 +0000 |
commit | bbb9d4fde31f44a70a6fb42181dc86cb91791d7e (patch) | |
tree | 0b4710c307ae07243760387090df2a799f4e2830 /newlib/libc/stdlib/__call_atexit.c | |
parent | 2beb9fbb02a83e61584e6fa838fd6d75bdd12e4f (diff) | |
download | cygnal-bbb9d4fde31f44a70a6fb42181dc86cb91791d7e.tar.gz cygnal-bbb9d4fde31f44a70a6fb42181dc86cb91791d7e.tar.bz2 cygnal-bbb9d4fde31f44a70a6fb42181dc86cb91791d7e.zip |
2009-04-23 Paul Brook <paul@codesourcery.com>
Kazu Hirata <kazu@codesourcery.com>
* libc/stdlib/__atexit.c (__register_exitproc): Use weak reference
to malloc. Allocate dynamically only if it is present.
* libc/stdlib/__call_atexit.c (__call_exitprocs): Use weak
reference to free. Call free only if it is present.
Diffstat (limited to 'newlib/libc/stdlib/__call_atexit.c')
-rw-r--r-- | newlib/libc/stdlib/__call_atexit.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c index ab86fcafa..e7f956184 100644 --- a/newlib/libc/stdlib/__call_atexit.c +++ b/newlib/libc/stdlib/__call_atexit.c @@ -7,6 +7,9 @@ #include <reent.h> #include "atexit.h" +/* Make this a weak reference to avoid pulling in free. */ +void free(void *) _ATTRIBUTE((__weak__)); + /* * Call registered exit handlers. If D is null then all handlers are called, * otherwise only the handlers from that DSO are called. @@ -76,6 +79,11 @@ _DEFUN (__call_exitprocs, (code, d), #ifndef _ATEXIT_DYNAMIC_ALLOC break; #else + /* Don't dynamically free the atexit array if free is not + available. */ + if (!free) + break; + /* Move to the next block. Free empty blocks except the last one, which is part of _GLOBAL_REENT. */ if (p->_ind == 0 && p->_next) |