diff lwlib/lw_expr.c @ 43:18b49cf10ae9

Added an instruction reduction immediately after instruction parsing to minimize memory footprint and expression complexity
author lost@l-w.ca
date Mon, 04 Apr 2011 17:55:08 -0600
parents 6b9991fb39b6
children b5785eb3441f
line wrap: on
line diff
--- a/lwlib/lw_expr.c	Sat Apr 02 22:37:41 2011 -0600
+++ b/lwlib/lw_expr.c	Mon Apr 04 17:55:08 2011 -0600
@@ -40,6 +40,9 @@
 
 int lw_expr_istype(lw_expr_t e, int t)
 {
+	/* NULL expression is never of any type */
+	if (!e)
+		return 0;
 	if (e -> type == t)
 		return 1;
 	return 0;
@@ -115,6 +118,8 @@
 	lw_expr_t r;
 	struct lw_expr_opers *o;
 	
+	if (!E)
+		return NULL;
 	r = lw_alloc(sizeof(struct lw_expr_priv));
 	*r = *E;
 	r -> operands = NULL;