blob: c4525914fb5503d84bceab6797a35fa9c9a57263 (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <stdio.h>
#include <stdlib.h>
struct s {
int i;
};
static void fv(struct s *s)
{
/* Do something with s */
free(s);
s = NULL;
}
static void fr(struct s **s)
{
/* Do something with s */
free(*s);
*s = NULL;
}
int main(void)
{
struct s *s;
s = malloc(sizeof(*s));
printf("s: %p\n", s);
fv(s);
printf("s: %p\n", s);
printf("\n");
s = malloc(sizeof(*s));
printf("s: %p\n", s);
fr(&s);
printf("s: %p\n", s);
return 0;
}
|