comparison directive.c @ 38:b156910b59b2

Wrap free() in dofree() to allow instrumenting it for debugging.
author David A. Holland
date Sat, 30 Mar 2013 21:02:25 -0400
parents a489cc223483
children 337110e7240a
comparison
equal deleted inserted replaced
37:70902cac4170 38:b156910b59b2
92 92
93 static 93 static
94 void 94 void
95 ifstate_destroy(struct ifstate *is) 95 ifstate_destroy(struct ifstate *is)
96 { 96 {
97 free(is); 97 dofree(is);
98 } 98 }
99 99
100 static 100 static
101 void 101 void
102 ifstate_push(struct place *p, bool startstate) 102 ifstate_push(struct place *p, bool startstate)
124 struct place p3 = *p2; 124 struct place p3 = *p2;
125 125
126 expr = macroexpand(p2, line, len, true); 126 expr = macroexpand(p2, line, len, true);
127 val = eval(&p3, expr); 127 val = eval(&p3, expr);
128 ifstate_push(p, val); 128 ifstate_push(p, val);
129 free(expr); 129 dofree(expr);
130 } 130 }
131 131
132 static 132 static
133 void 133 void
134 d_ifdef(struct place *p, struct place *p2, char *line, size_t len) 134 d_ifdef(struct place *p, struct place *p2, char *line, size_t len)
161 ifstate->curtrue = false; 161 ifstate->curtrue = false;
162 } else { 162 } else {
163 expr = macroexpand(p2, line, len, true); 163 expr = macroexpand(p2, line, len, true);
164 ifstate->curtrue = eval(&p3, expr); 164 ifstate->curtrue = eval(&p3, expr);
165 ifstate->evertrue = ifstate->curtrue; 165 ifstate->evertrue = ifstate->curtrue;
166 free(expr); 166 dofree(expr);
167 } 167 }
168 } 168 }
169 169
170 static 170 static
171 void 171 void
296 if (tryinclude(p, line, len)) { 296 if (tryinclude(p, line, len)) {
297 return; 297 return;
298 } 298 }
299 text = macroexpand(p2, line, len, false); 299 text = macroexpand(p2, line, len, false);
300 if (tryinclude(p, text, strlen(text))) { 300 if (tryinclude(p, text, strlen(text))) {
301 free(text); 301 dofree(text);
302 return; 302 return;
303 } 303 }
304 free(text); 304 dofree(text);
305 complain(p, "Illegal #include directive"); 305 complain(p, "Illegal #include directive");
306 complain_fail(); 306 complain_fail();
307 } 307 }
308 308
309 static 309 static
326 msg = macroexpand(p2, line, len, false); 326 msg = macroexpand(p2, line, len, false);
327 complain(p, "#warning: %s", msg); 327 complain(p, "#warning: %s", msg);
328 if (mode.werror) { 328 if (mode.werror) {
329 complain_fail(); 329 complain_fail();
330 } 330 }
331 free(msg); 331 dofree(msg);
332 } 332 }
333 333
334 static 334 static
335 void 335 void
336 d_error(struct place *p, struct place *p2, char *line, size_t len) 336 d_error(struct place *p, struct place *p2, char *line, size_t len)
338 char *msg; 338 char *msg;
339 339
340 msg = macroexpand(p2, line, len, false); 340 msg = macroexpand(p2, line, len, false);
341 complain(p, "#error: %s", msg); 341 complain(p, "#error: %s", msg);
342 complain_fail(); 342 complain_fail();
343 free(msg); 343 dofree(msg);
344 } 344 }
345 345
346 //////////////////////////////////////////////////////////// 346 ////////////////////////////////////////////////////////////
347 // other 347 // other
348 348