comparison place.c @ 11:b9d50e786322

simplify places
author David A. Holland
date Sun, 19 Dec 2010 19:30:24 -0500
parents 800f3a560a3b
children 6c15ca895585
comparison
equal deleted inserted replaced
10:800f3a560a3b 11:b9d50e786322
17 bool fromsystemdir; 17 bool fromsystemdir;
18 }; 18 };
19 DECLARRAY(seenfile); 19 DECLARRAY(seenfile);
20 DEFARRAY(seenfile, ); 20 DEFARRAY(seenfile, );
21 21
22 static struct seenfilearray seenfiles;
22 static bool overall_failure; 23 static bool overall_failure;
23
24 static struct place scratchplace;
25 static bool scratchplace_inuse;
26
27 static struct seenfilearray seenfiles;
28 24
29 //////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////
30 // seenfiles 26 // seenfiles
31 27
32 static 28 static
82 static 78 static
83 bool 79 bool
84 place_iscommandline(const struct place *p) 80 place_iscommandline(const struct place *p)
85 { 81 {
86 return p->file == NULL && p->line == COMMANDLINE_LINE; 82 return p->file == NULL && p->line == COMMANDLINE_LINE;
87 }
88
89 struct place *
90 place_gettemporary(void)
91 {
92 assert(!scratchplace_inuse);
93 scratchplace_inuse = true;
94 return &scratchplace;
95 }
96
97 void
98 place_puttemporary(struct place *p)
99 {
100 assert(scratchplace_inuse);
101 assert(p == &scratchplace);
102 scratchplace_inuse = false;
103 }
104
105 struct place *
106 place_create(void)
107 {
108 struct place *p;
109
110 p = domalloc(sizeof(*p));
111 place_setnowhere(p);
112 return p;
113 }
114
115 struct place *
116 place_clone(const struct place *op)
117 {
118 struct place *p;
119
120 p = domalloc(sizeof(*p));
121 *p = *op;
122 return p;
123 }
124
125 void
126 place_destroy(struct place *p)
127 {
128 free(p);
129 } 83 }
130 84
131 void 85 void
132 place_setnowhere(struct place *p) 86 place_setnowhere(struct place *p)
133 { 87 {