1 /* taken from wine exit.c */ 2 #include <precomp.h> 3 4 /********************************************************************* 5 * __dllonexit (MSVCRT.@) 6 */ 7 _onexit_t CDECL __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end) 8 { 9 _onexit_t *tmp; 10 size_t len; 11 12 TRACE("(%p,%p,%p)\n", func, start, end); 13 14 if (!start || !*start || !end || !*end) 15 { 16 FIXME("bad table\n"); 17 return NULL; 18 } 19 20 len = (*end - *start); 21 22 TRACE("table start %p-%p, %d entries\n", *start, *end, len); 23 24 if (++len <= 0) 25 return NULL; 26 27 tmp = realloc(*start, len * sizeof(_onexit_t)); 28 if (!tmp) 29 return NULL; 30 *start = tmp; 31 *end = tmp + len; 32 tmp[len - 1] = func; 33 TRACE("new table start %p-%p, %d entries\n", *start, *end, len); 34 return func; 35 } 36