comparison lwlib/lw_expr.c @ 438:22bbb716dea6 3.0

Fixed memory leaks related to expressions; bumped version to 3.0.1
author lost@l-w.ca
date Sat, 30 Oct 2010 10:40:26 -0600
parents d7d7e4dca3e7
children 367bdde181be
comparison
equal deleted inserted replaced
436:4c272633fce2 438:22bbb716dea6
95 void lw_expr_destroy(lw_expr_t E) 95 void lw_expr_destroy(lw_expr_t E)
96 { 96 {
97 struct lw_expr_opers *o; 97 struct lw_expr_opers *o;
98 if (!E) 98 if (!E)
99 return; 99 return;
100 for (o = E -> operands; o; o = o -> next) 100 while (E -> operands)
101 {
102 o = E -> operands;
103 E -> operands = o -> next;
101 lw_expr_destroy(o -> p); 104 lw_expr_destroy(o -> p);
105 lw_Free(o);
106 }
102 if (E -> type == lw_expr_type_var) 107 if (E -> type == lw_expr_type_var)
103 lw_free(E -> value2); 108 lw_free(E -> value2);
104 lw_free(E); 109 lw_free(E);
105 } 110 }
106 111
117 122
118 if (E -> type == lw_expr_type_var) 123 if (E -> type == lw_expr_type_var)
119 r -> value2 = lw_strdup(E -> value2); 124 r -> value2 = lw_strdup(E -> value2);
120 for (o = E -> operands; o; o = o -> next) 125 for (o = E -> operands; o; o = o -> next)
121 { 126 {
122 lw_expr_add_operand(r, lw_expr_copy(o -> p)); 127 lw_expr_add_operand(r, o -> p);
123 } 128 }
124 129
125 return r; 130 return r;
126 } 131 }
127 132