ReactOS 0.4.16-dev-2122-g1628f5e
onexit.c File Reference
#include <process.h>
#include "msvcrt.h"
#include "mtdll.h"
Include dependency graph for onexit.c:

Go to the source code of this file.

Functions

int __cdecl _initialize_onexit_table (_onexit_table_t *table)
 
int __cdecl _register_onexit_function (_onexit_table_t *table, _onexit_t func)
 
int __cdecl _execute_onexit_table (_onexit_table_t *table)
 

Function Documentation

◆ _execute_onexit_table()

int __cdecl _execute_onexit_table ( _onexit_table_t table)

Definition at line 91 of file onexit.c.

92{
93 _PVFV *func;
95
96 if (!table)
97 return -1;
98
100 if (!table->_first || table->_first >= table->_last)
101 {
103 return 0;
104 }
105 copy._first = table->_first;
106 copy._last = table->_last;
107 copy._end = table->_end;
108 memset(table, 0, sizeof(*table));
111
112 for (func = copy._last - 1; func >= copy._first; func--)
113 {
114 if (*func)
115 (*func)();
116 }
117
118 HeapFree(GetProcessHeap(), 0, copy._first);
119 return 0;
120}
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
void(__cdecl * _PVFV)(void)
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
#define _EXIT_LOCK1
Definition: mtdll.h:37
GLenum func
Definition: glext.h:6028
int __cdecl _initialize_onexit_table(_onexit_table_t *table)
Definition: onexit.c:34
#define memset(x, y, z)
Definition: compat.h:39

◆ _initialize_onexit_table()

int __cdecl _initialize_onexit_table ( _onexit_table_t table)

Definition at line 34 of file onexit.c.

35{
36 if (!table)
37 return -1;
38
39 if (table->_first == table->_end)
40 table->_last = table->_end = table->_first = NULL;
41 return 0;
42}
#define NULL
Definition: types.h:112

Referenced by _execute_onexit_table().

◆ _register_onexit_function()

int __cdecl _register_onexit_function ( _onexit_table_t table,
_onexit_t  func 
)

Definition at line 48 of file onexit.c.

49{
50 if (!table)
51 return -1;
52
54 if (!table->_first)
55 {
56 table->_first = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(void *));
57 if (!table->_first)
58 {
60 return -1;
61 }
62 table->_last = table->_first;
63 table->_end = table->_first + 32;
64 }
65
66 /* grow if full */
67 if (table->_last == table->_end)
68 {
69 int len = table->_end - table->_first;
70 _PVFV *tmp = HeapReAlloc(GetProcessHeap(), 0, table->_first, 2 * len * sizeof(void *));
71 if (!tmp)
72 {
74 return -1;
75 }
76 table->_first = tmp;
77 table->_end = table->_first + 2 * len;
78 table->_last = table->_first + len;
79 }
80
81 *table->_last = (_PVFV)func;
82 table->_last++;
84 return 0;
85}
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLenum GLsizei len
Definition: glext.h:6722