xref: /reactos/sdk/lib/crt/misc/initterm.c (revision 50cf16b3)
1 #include <precomp.h>
2 
3 typedef void (CDECL *_INITTERMFUN)(void);
4 typedef int (CDECL *_INITTERM_E_FN)(void);
5 
6 
7 /*********************************************************************
8  *		_initterm (MSVCRT.@)
9  */
10 void CDECL _initterm(_INITTERMFUN *start,_INITTERMFUN *end)
11 {
12   _INITTERMFUN* current = start;
13 
14   TRACE("(%p,%p)\n",start,end);
15   while (current<end)
16   {
17     if (*current)
18     {
19       TRACE("Call init function %p\n",*current);
20       (**current)();
21       TRACE("returned\n");
22     }
23     current++;
24   }
25 }
26 
27 /*********************************************************************
28  *  _initterm_e (MSVCRT.@)
29  *
30  * call an array of application initialization functions and report the return value
31  */
32 int CDECL _initterm_e(_INITTERM_E_FN *table, _INITTERM_E_FN *end)
33 {
34     int res = 0;
35 
36     TRACE("(%p, %p)\n", table, end);
37 
38     while (!res && table < end) {
39         if (*table) {
40             TRACE("calling %p\n", **table);
41             res = (**table)();
42             if (res)
43                 TRACE("function %p failed: 0x%x\n", *table, res);
44 
45         }
46         table++;
47     }
48     return res;
49 }
50