Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / test / sharing2.c
blob0fdd148ba260df4bc72e8c75d58605c33eae6aa0
1 extern /*@out@*/ /*@only@*/ void *smalloc (unsigned int size);
3 typedef int mint;
5 typedef struct _st
7 int a;
8 /*@only@*/ int *b;
9 /*@shared@*/ mint *c;
10 int d;
11 } *st;
13 /*@only@*/ st st_create1 ()
15 st res = (st) smalloc (sizeof(struct _st));
16 int *z;
18 res->a = 3;
19 z = res->b; /* res->b not defined */
20 z = (*res).c; /* (*res).c not defined */
22 return res; /* res->d not defined */
25 void f1(/*@only@*/ st x)
27 free (x->b);
28 free (x);
29 } /* correct */
31 void f2(/*@only@*/ st x)
33 free (x);
34 } /* bad --- didn't release x->b */
36 void f3(/*@only@*/ st x)
38 free (x->c); /* bad --- x->c is shared */
39 } /* bad --- didn't release x */
41 /*@only@*/ st st_create ()
43 st res = (st) smalloc(sizeof(struct _st));
44 res->a = 3;
45 return res; /* 6, 7, 8. res->b, res->c, res->d not defined */