diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1999-03-30 17:24:31 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1999-03-30 17:24:31 -0500 |
commit | 327b7c16889c9d95ec076d695c970da11dc32a2b (patch) | |
tree | 91a9c864c60dfff69efe63d4cca7aab0b4754d6d /src/LYexit.c | |
parent | 79de405977ac0d7820576b353dde07ce09cedba9 (diff) | |
download | lynx-snapshots-327b7c16889c9d95ec076d695c970da11dc32a2b.tar.gz |
snapshot of project "lynx", label v2-8-2dev_21
Diffstat (limited to 'src/LYexit.c')
-rw-r--r-- | src/LYexit.c | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/src/LYexit.c b/src/LYexit.c index 4bcda3c5..67549ae4 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -15,20 +15,72 @@ #endif /* !VMS */ /* + * Flag for outofmem macro. - FM + */ +PUBLIC BOOL LYOutOfMemory = FALSE; + +#ifdef LY_FIND_LEAKS + +/* * Stack of functions to call upon exit. */ PRIVATE void (*callstack[ATEXITSIZE]) NOPARAMS; PRIVATE int topOfStack = 0; /* - * Flag for outofmem macro. - FM + * Purpose: Registers termination function. + * Arguments: function The function to register. + * Return Value: int 0 registered + * !0 no more space to register + * Remarks/Portability/Dependencies/Restrictions: + * Revision History: + * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe */ -PUBLIC BOOL LYOutOfMemory = FALSE; + +#ifdef __STDC__ +PUBLIC int LYatexit(void (*function)(void)) +#else /* Not ANSI, ugh! */ +PUBLIC int LYatexit(function) +void (*function)(); +#endif /* __STDC__ */ +{ + /* + * Check for available space. + */ + if (topOfStack == ATEXITSIZE) { + CTRACE(tfp, "(LY)atexit: Too many functions, ignoring one!\n"); + return(-1); + } + + /* + * Register the function. + */ + callstack[topOfStack] = function; + topOfStack++; + return(0); +} /* - * Forward declarations. + * Purpose: Call the functions registered with LYatexit + * Arguments: void + * Return Value: void + * Remarks/Portability/Dependencies/Restrictions: + * Revision History: + * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe */ -PRIVATE void LYCompleteExit NOPARAMS; +PRIVATE void LYCompleteExit NOPARAMS +{ + /* + * Just loop through registered functions. + * This is reentrant if more exits occur in the registered functions. + */ + while (--topOfStack >= 0) { + callstack[topOfStack](); + } +} +#else +#define LYCompleteExit() /*nothing*/ +#endif /* LY_FIND_LEAKS */ /* * Purpose: Terminates program. @@ -116,57 +168,6 @@ PUBLIC void LYexit ARGS1( exit(status); } -/* - * Purpose: Registers termination function. - * Arguments: function The function to register. - * Return Value: int 0 registered - * !0 no more space to register - * Remarks/Portability/Dependencies/Restrictions: - * Revision History: - * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe - */ -#ifdef __STDC__ -PUBLIC int LYatexit(void (*function)(void)) -#else /* Not ANSI, ugh! */ -PUBLIC int LYatexit(function) -void (*function)(); -#endif /* __STDC__ */ -{ - /* - * Check for available space. - */ - if (topOfStack == ATEXITSIZE) { - CTRACE(tfp, "(LY)atexit: Too many functions, ignoring one!\n"); - return(-1); - } - - /* - * Register the function. - */ - callstack[topOfStack] = function; - topOfStack++; - return(0); -} - -/* - * Purpose: Call the functions registered with LYatexit - * Arguments: void - * Return Value: void - * Remarks/Portability/Dependencies/Restrictions: - * Revision History: - * 06-15-94 created Lynx 2-3-1 Garrett Arch Blythe - */ -PRIVATE void LYCompleteExit NOPARAMS -{ - /* - * Just loop through registered functions. - * This is reentrant if more exits occur in the registered functions. - */ - while (--topOfStack >= 0) { - callstack[topOfStack](); - } -} - PUBLIC void outofmem ARGS2( CONST char *, fname, CONST char *, func) |