Commit b6779252 authored by Karl Heuer's avatar Karl Heuer

[DOUG_LEA_MALLOC] (malloc_initialize_hook):

Move the handling of MALLOC_CHECK_ envvar here.
(main): Moved from here.

[DOUG_LEA_MALLOC] (malloc_initialize_hook): New
function, assigned to the global __malloc_initialize_hook pointer.
(main): Move malloc_set_state call into malloc_initialize_hook
so that it happens as early as possible.
parent 9a1136f4
......@@ -545,27 +545,17 @@ argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr)
}
}
/* ARGSUSED */
int
main (argc, argv, envp)
int argc;
char **argv;
char **envp;
{
char stack_bottom_variable;
int skip_args = 0;
extern int errno;
extern int sys_nerr;
#ifdef HAVE_SETRLIMIT
struct rlimit rlim;
#endif
int no_loadup = 0;
#ifdef DOUG_LEA_MALLOC
#ifdef LINUX_SBRK_BUG
__sbrk (1);
#endif
/* malloc can be invoked even before main (e.g. by the dynamic
linker), so the dumped malloc state must be restored as early as
possible using this special hook. */
static void
malloc_initialize_hook ()
{
extern char **environ;
#ifdef DOUG_LEA_MALLOC
if (initialized)
{
if (!malloc_using_checking)
......@@ -575,7 +565,7 @@ main (argc, argv, envp)
{
char **p;
for (p = envp; *p; p++)
for (p = environ; *p; p++)
if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0)
{
do
......@@ -584,11 +574,36 @@ main (argc, argv, envp)
break;
}
}
malloc_set_state (malloc_state_ptr);
free (malloc_state_ptr);
}
else
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
}
void (*__malloc_initialize_hook) () = malloc_initialize_hook;
#endif /* DOUG_LEA_MALLOC */
/* ARGSUSED */
int
main (argc, argv, envp)
int argc;
char **argv;
char **envp;
{
char stack_bottom_variable;
int skip_args = 0;
extern int errno;
extern int sys_nerr;
#ifdef HAVE_SETRLIMIT
struct rlimit rlim;
#endif
int no_loadup = 0;
#ifdef LINUX_SBRK_BUG
__sbrk (1);
#endif
#ifdef RUN_TIME_REMAP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment