You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exit() calls the internal function _tidyup() to clean up, this should be equivalent to modern C's atexit list. We should be able to refactor this code so that there is a linked list of exit functions, something like
by default, there is a single function pointer pointing to the original _tidyup() function, and with a "next" pointer of NULL. Calling atexit(myfunc) allocates a new structure (two pointers) with ibrk(); assigns the head of the exit func list to the address of 'myfunc', then sets the 'next' pointer to the old head.
Inside exit(), we can then do the equivalent of
for (func=top->_ex_fptr; func; func=top=top->_ex_next)
(*func)();
The text was updated successfully, but these errors were encountered:
exit()
calls the internal function_tidyup()
to clean up, this should be equivalent to modern C's atexit list. We should be able to refactor this code so that there is a linked list of exit functions, something likeby default, there is a single function pointer pointing to the original
_tidyup()
function, and with a "next" pointer of NULL. Callingatexit(myfunc)
allocates a new structure (two pointers) withibrk()
; assigns the head of the exit func list to the address of 'myfunc', then sets the 'next' pointer to the old head.Inside
exit()
, we can then do the equivalent ofThe text was updated successfully, but these errors were encountered: