]> pd.if.org Git - pdclib/blob - functions/stdlib/atexit.c
Moved struct definition to internal header.
[pdclib] / functions / stdlib / atexit.c
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* atexit( void (*)( void ) )
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #include <stdlib.h>
12
13 #ifndef REGTEST
14
15 extern struct _PDCLIB_exitfunc_t * regstack;
16
17 int atexit( void (*func)( void ) )
18 {
19     struct _PDCLIB_exitfunc_t * regfunc = (struct _PDCLIB_exitfunc_t *)malloc( sizeof( struct _PDCLIB_exitfunc_t ) );
20     if ( regfunc == NULL )
21     {
22         return -1;
23     }
24     else
25     {
26         regfunc->func = func;
27         regfunc->next = regstack;
28         regstack = regfunc;
29         return 0;
30     }
31 }
32
33 #endif
34
35 #ifdef TEST
36 #include <_PDCLIB_test.h>
37
38 int main()
39 {
40     int NO_TESTDRIVER = 0;
41     BEGIN_TESTS;
42     TESTCASE( NO_TESTDRIVER );
43     return TEST_RESULTS;
44 }
45
46 #endif