5 /* atexit( void (*)( void ) )
7 This file is part of the Public Domain C Library (PDCLib).
8 Permission is granted to use, modify, and / or redistribute at will.
15 extern struct _PDCLIB_exitfunc_t * regstack;
17 int atexit( void (*func)( void ) )
19 struct _PDCLIB_exitfunc_t * regfunc = (struct _PDCLIB_exitfunc_t *)malloc( sizeof( struct _PDCLIB_exitfunc_t ) );
20 if ( regfunc == NULL )
27 regfunc->next = regstack;
36 #include <_PDCLIB_test.h>
39 static int flags[ 32 ];
41 static void counthandler()
48 static void checkhandler()
50 for ( int i = 0; i < 31; ++i )
52 assert( flags[ i ] == i );
59 TESTCASE( atexit( &checkhandler ) == 0 );
60 for ( int i = 0; i < 31; ++i )
62 TESTCASE( atexit( &counthandler ) == 0 );