comparison lwlib/lw_expr.c @ 92:19ca3108a223

Fixed numerous *common* memory leaks in epxression code
author lost@l-w.ca
date Wed, 22 Jun 2011 19:13:06 -0600
parents b5785eb3441f
children db5690682eb7
comparison
equal deleted inserted replaced
91:95181f1ad183 92:19ca3108a223
573 573
574 if (te -> type == lw_expr_type_var) 574 if (te -> type == lw_expr_type_var)
575 E -> value2 = lw_strdup(te -> value2); 575 E -> value2 = lw_strdup(te -> value2);
576 for (o = te -> operands; o; o = o -> next) 576 for (o = te -> operands; o; o = o -> next)
577 { 577 {
578 lw_expr_add_operand(E, lw_expr_copy(o -> p)); 578 lw_expr_t xxx;
579 xxx = lw_expr_copy(o -> p);
580 lw_expr_add_operand(E, xxx);
581 lw_expr_destroy(xxx);
579 } 582 }
580 lw_expr_destroy(te); 583 lw_expr_destroy(te);
581 goto again; 584 goto again;
582 } 585 }
583 return; 586 return;
930 E -> operands = o -> next; 933 E -> operands = o -> next;
931 lw_expr_destroy(o -> p); 934 lw_expr_destroy(o -> p);
932 lw_free(o); 935 lw_free(o);
933 } 936 }
934 *E = *r; 937 *E = *r;
938 lw_free(r);
935 return; 939 return;
936 } 940 }
937 else if (c == 0) 941 else if (c == 0)
938 { 942 {
939 // replace with 0 943 // replace with 0
1001 1005
1002 for (o = E2 -> operands; o; o = o -> next) 1006 for (o = E2 -> operands; o; o = o -> next)
1003 { 1007 {
1004 t1 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_times, E3, o -> p); 1008 t1 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_times, E3, o -> p);
1005 lw_expr_add_operand(E, t1); 1009 lw_expr_add_operand(E, t1);
1010 lw_expr_destroy(t1);
1006 } 1011 }
1007 1012
1008 lw_expr_destroy(E2); 1013 lw_expr_destroy(E2);
1009 lw_expr_destroy(E3); 1014 lw_expr_destroy(E3);
1010 } 1015 }