We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2bcc553 commit 5dafcefCopy full SHA for 5dafcef
1 file changed
test/malloc.c
@@ -26,11 +26,18 @@ point_ptr mk_point()
26
// TODO: > INT32_MIN
27
#define INT32_FITS(x) ((x) >= 0 && (x) < INT32_MAX)
28
29
+int sum_point(const point_ptr p)
30
+ _requires(INT32_FITS((_specint) p->x + p->y))
31
+ _ensures(return == _old(p->x + p->y))
32
+{
33
+ return p->x + p->y;
34
+}
35
+
36
int sum_and_free_point(_consumes point_ptr p)
37
_requires(INT32_FITS((_specint) p->x + p->y))
38
_ensures(return == _old(p->x + p->y))
39
{
- int sum = p->x + p->y;
40
+ int sum = sum_point(p);
41
free(p);
42
return sum;
43
}
0 commit comments