summaryrefslogtreecommitdiff
path: root/ccan/tal/talloc/test/run-free.c
blob: 0dee0a70b1a1e14f869460316649883cbb6e0594 (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
26
#include <ccan/tal/talloc/talloc.h>
#include <ccan/tal/talloc/talloc.c>
#include <ccan/tap/tap.h>
#include <errno.h>

static void destroy_errno(char *p)
{
	errno = ENOENT;
}

int main(void)
{
	char *p;

	plan_tests(2);

	p = tal(NULL, char);
	ok1(tal_add_destructor(p, destroy_errno));

	/* Errno save/restored across free. */
	errno = EINVAL;
	tal_free(p);
	ok1(errno == EINVAL);

	return exit_status();
}