shithub: scc

ref: eba17d80d42e07d4eb9176c66d1bbb3ee39e8d81
dir: /libc/src/atexit.c/

View raw version
/* See LICENSE file for copyright and license details. */

#include <stdlib.h>
#undef atexit

extern void (*_atexitf[_ATEXIT_MAX])(void);

int
atexit(void (*fun)(void))
{
	void (**bp)(void);

	for (bp = _atexitf; bp < &_atexitf[_ATEXIT_MAX] && *bp; ++bp)
		/* nothing */;
	if (bp == &_atexitf[_ATEXIT_MAX])
		return 0;
	*bp = fun;
	return 1;
}