diff options
| author | Karl Heuer | 1999-06-29 17:14:31 +0000 |
|---|---|---|
| committer | Karl Heuer | 1999-06-29 17:14:31 +0000 |
| commit | b67792520cd64cf1875fc14084dce1bd78e33b6b (patch) | |
| tree | eba1db92d2f35d8ce6c6eeb8aa8da92a388676f8 /src | |
| parent | 9a1136f4de4a20231cac5a8894bf598250cc4ec3 (diff) | |
| download | emacs-b67792520cd64cf1875fc14084dce1bd78e33b6b.tar.gz emacs-b67792520cd64cf1875fc14084dce1bd78e33b6b.zip | |
[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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/src/emacs.c b/src/emacs.c index 859e1dd9fd3..5721c2c9826 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -545,27 +545,17 @@ argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr) | |||
| 545 | } | 545 | } |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | /* ARGSUSED */ | 548 | #ifdef DOUG_LEA_MALLOC |
| 549 | int | ||
| 550 | main (argc, argv, envp) | ||
| 551 | int argc; | ||
| 552 | char **argv; | ||
| 553 | char **envp; | ||
| 554 | { | ||
| 555 | char stack_bottom_variable; | ||
| 556 | int skip_args = 0; | ||
| 557 | extern int errno; | ||
| 558 | extern int sys_nerr; | ||
| 559 | #ifdef HAVE_SETRLIMIT | ||
| 560 | struct rlimit rlim; | ||
| 561 | #endif | ||
| 562 | int no_loadup = 0; | ||
| 563 | 549 | ||
| 564 | #ifdef LINUX_SBRK_BUG | 550 | /* malloc can be invoked even before main (e.g. by the dynamic |
| 565 | __sbrk (1); | 551 | linker), so the dumped malloc state must be restored as early as |
| 566 | #endif | 552 | possible using this special hook. */ |
| 553 | |||
| 554 | static void | ||
| 555 | malloc_initialize_hook () | ||
| 556 | { | ||
| 557 | extern char **environ; | ||
| 567 | 558 | ||
| 568 | #ifdef DOUG_LEA_MALLOC | ||
| 569 | if (initialized) | 559 | if (initialized) |
| 570 | { | 560 | { |
| 571 | if (!malloc_using_checking) | 561 | if (!malloc_using_checking) |
| @@ -575,7 +565,7 @@ main (argc, argv, envp) | |||
| 575 | { | 565 | { |
| 576 | char **p; | 566 | char **p; |
| 577 | 567 | ||
| 578 | for (p = envp; *p; p++) | 568 | for (p = environ; *p; p++) |
| 579 | if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0) | 569 | if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0) |
| 580 | { | 570 | { |
| 581 | do | 571 | do |
| @@ -584,11 +574,36 @@ main (argc, argv, envp) | |||
| 584 | break; | 574 | break; |
| 585 | } | 575 | } |
| 586 | } | 576 | } |
| 577 | |||
| 587 | malloc_set_state (malloc_state_ptr); | 578 | malloc_set_state (malloc_state_ptr); |
| 588 | free (malloc_state_ptr); | 579 | free (malloc_state_ptr); |
| 589 | } | 580 | } |
| 590 | else | 581 | else |
| 591 | malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; | 582 | malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; |
| 583 | } | ||
| 584 | |||
| 585 | void (*__malloc_initialize_hook) () = malloc_initialize_hook; | ||
| 586 | |||
| 587 | #endif /* DOUG_LEA_MALLOC */ | ||
| 588 | |||
| 589 | /* ARGSUSED */ | ||
| 590 | int | ||
| 591 | main (argc, argv, envp) | ||
| 592 | int argc; | ||
| 593 | char **argv; | ||
| 594 | char **envp; | ||
| 595 | { | ||
| 596 | char stack_bottom_variable; | ||
| 597 | int skip_args = 0; | ||
| 598 | extern int errno; | ||
| 599 | extern int sys_nerr; | ||
| 600 | #ifdef HAVE_SETRLIMIT | ||
| 601 | struct rlimit rlim; | ||
| 602 | #endif | ||
| 603 | int no_loadup = 0; | ||
| 604 | |||
| 605 | #ifdef LINUX_SBRK_BUG | ||
| 606 | __sbrk (1); | ||
| 592 | #endif | 607 | #endif |
| 593 | 608 | ||
| 594 | #ifdef RUN_TIME_REMAP | 609 | #ifdef RUN_TIME_REMAP |