### _CRT_term -- Terminate DLL Runtime Environment

Format

>     void _CRT_term(void);
>     /* no header file - defined in runtime startup code */

Language Level: Extension
_CRT_term terminates the IBM C and C++ Compilers runtime environment.

By default, all DLLs call the IBM C and C++ Compilers _DLL_InitTerm function, which in turn calls _CRT_term for you. However, if you are writing your own _DLL_InitTerm function (for example, to perform actions other than runtime initialization and termination), you must call _CRT_term from your _DLL_InitTerm function. If _CRT_init has been called, there must be a matching _CRT_term to insure library termination.

If your DLL contains C++ code, you must also call __ctordtorTerm before you call _CRT_term to ensure that static constructors and destructors are terminated correctly.

The prototype for __ctordtorTerm is void_ctordtorTerm( int flag ). Value 0 for flag means that destructors are called for process termination. Value 1 means that only destructors for thread specific objects in the current thread should be called.

Once you have called _CRT_term, you cannot call any other library functions.

_CRT_term flushes the file buffers, but does not perform a complete library shutdown until the last user of the library calls _CRT_term. This is done by incrementing a use counter in _CRT_init, and decrementing it in _CRT_term. When the count reaches zero, the complete library shutdown occurs (files and semaphores are closed and the heap is destroyed). This prevents premature library shutdown because the DLL termination order is always predictable.

Failing to provide a matching call to _CRT_term could, under some circumstances, cause a DLL loaded by DosLoadModule or _loadmod, to fail to release its resources when it is freed.

On OS/2, if your DLL is dynamically linked, you cannot call library functions in the termination section of your _DLL_InitTerm function. If your termination routine requires calling library functions, you must register the termination routine with DosExitList. Note that all DosExitList routines are called before DLL termination routines.

Return Value
There is no return value for _CRT_term.

Example

_CRT_init -- Initialize DLL Runtime Environment
_DLL_InitTerm -- Initialize and Terminate DLL Environment
_rmem_init -- Initialize Memory Functions for Subsystem DLL
_rmem_term -- Terminate Memory Functions for Subsystem DLL
_tmem_init -- Initialize Memory Functions for Subsystem DLL
_tmem_term -- Terminate Memory Functions for Subsystem DLL