-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.c
More file actions
29 lines (24 loc) · 757 Bytes
/
test.c
File metadata and controls
29 lines (24 loc) · 757 Bytes
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
27
28
29
#include <stdlib.h>
#include "smart.h"
static void test_single () {
char *x = (char *) free_on_exit (malloc (sizeof (char)));
}
static void test_multiple () {
char *x[] = {0, 0, 0};
x[0] = (char *) free_on_exit (malloc (sizeof (char)));
x[1] = (char *) free_on_exit (malloc (sizeof (char)));
x[2] = (char *) free_on_exit (malloc (sizeof (char)));
}
static void test_nested () {
char *x = (char *) free_on_exit (malloc (sizeof (char)));
test_single ();
test_multiple ();
}
/* Run this with valgrind. You may need to install 32 bit debug
* symbols for the C library. On Ubuntu this is libc6-dbg:i386.
* See https://stackoverflow.com/q/10172302/774658 */
int main () {
test_single ();
test_multiple ();
test_nested ();
}