summaryrefslogtreecommitdiff
path: root/ccan/talloc/test/run-test_autofree.c
blob: 0aa0c172c9fcbcf50d37b1d9954054a3d5a4e743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <ccan/talloc/talloc.c>
#include <stdbool.h>
#include <ccan/tap/tap.h>

static int destroy_int(int *p)
{
	ok1(*p == 7);
	_exit(0);
}

int main(int argc, char *argv[])
{
	int *p;

	/* If autofree context doesn't work, we won't run all tests! */
	plan_tests(1);

	p = talloc(talloc_autofree_context(), int);
	*p = 7;
	talloc_set_destructor(p, destroy_int);

	/* Note!  We fail here, unless destructor called! */
	exit(1);
}