summaryrefslogtreecommitdiffstats
path: root/usr/klibc/onexit.c
blob: 15a96b5595a8d46c38f24a2655af14a6f659276b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * onexit.c
 */

#include <stdlib.h>
#include <unistd.h>
#include "atexit.h"

int on_exit(void (*fctn) (int, void *), void *arg)
{
	struct atexit *as = malloc(sizeof(struct atexit));

	if (!as)
		return -1;

	as->fctn = fctn;
	as->arg = arg;

	as->next = __atexit_list;
	__atexit_list = as;

	return 0;
}