]> andersk Git - splint.git/blame - test/sharing3.c
Doing the commit so that files can be taged.
[splint.git] / test / sharing3.c
CommitLineData
885824d3 1extern /*@only@*/ char *string_copyext (char *s) ;
2
3void f (void)
4{
5 char *s;
6
7 if (3 < 4)
8 {
9 s = string_copyext ("asdf");
10 free (s);
11 }
12}
13
14
15/*@only@*/ char *string_copy (char *s)
16{
17 return s; /* 1. returns temp as only! */
18}
19
20/*@only@*/ char *copy_string1 (char *s)
21{
22 return string_copy (s); /* okay */
23}
24
25/*@only@*/ char *copy_string2 (char *s)
26{
27 return string_copyext (s); /* okay */
28}
29
30void string_free1 (char *s)
31{
32 free (s); /* 2. unqualified as only */
33}
34
35void string_free2 (/*@only@*/ char *s)
36{
37 free (s);
38}
39
40void string_free3 (/*@only@*/ char *s)
41{
42 char *t = string_copy (s);
43 string_free2 (s);
44 *t = 'a';
45} /* 3. bad, t not released */
46
47void string_free4 (/*@only@*/ char *s)
48{
49 char *t;
50 int i;
51
52 for (i = 0; i < 3; i++)
53 {
54 t = string_copy (s);
55 *t = 'a';
56 free (t);
57 }
58
59 free (s);
60} /* okay */
61
This page took 0.064312 seconds and 5 git commands to generate.