1 /* atexit( void (*)( void ) )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
11 extern void (*_PDCLIB_quickexitstack[])( void );
12 extern size_t _PDCLIB_quickexitptr;
14 int at_quick_exit( void (*func)( void ) )
16 if ( _PDCLIB_quickexitptr == 0 )
22 _PDCLIB_quickexitstack[ --_PDCLIB_quickexitptr ] = func;
30 #include "_PDCLIB_test.h"
33 static int flags[ 32 ];
35 static void counthandler( void )
38 flags[ count ] = count;
42 static void checkhandler( void )
44 for ( int i = 0; i < 31; ++i )
46 assert( flags[ i ] == i );
52 TESTCASE( at_quick_exit( &checkhandler ) == 0 );
53 for ( int i = 0; i < 31; ++i )
55 TESTCASE( at_quick_exit( &counthandler ) == 0 );