blob: 7407efa21e76d125837a142f651b4fffe49e4b0f (
plain)
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
42
43
44
45
46
47
|
/* { dg-skip-if "" { powerpc*-*-aix* } } */
/* { dg-additional-options "-O2" } */
#include <stdio.h>
#include <stdlib.h>
typedef struct AMARK {
struct AMARK *m_next;
char m_name;
} AMARK;
struct buf {
AMARK *b_amark;
};
struct buf *curbp;
int pamark(void) {
int c;
AMARK *p = curbp->b_amark;
AMARK *last = curbp->b_amark;
c = getchar();
while (p != (AMARK *)NULL && p->m_name != (char)c) {
last = p;
p = p->m_next;
}
if (p != (AMARK *)NULL) {
printf("over writing mark %c\n", c);
} else {
if ((p = (AMARK *)malloc(sizeof(AMARK))) == (AMARK *)NULL)
return 0;
p->m_next = (AMARK *)NULL;
if (curbp->b_amark == (AMARK *)NULL)
curbp->b_amark = p;
else
last->m_next = p;
}
p->m_name = (char)c; /* { dg-bogus "leak of 'p'" "bogus leak" } */
return 1;
}
|