فهرست منبع

expr engine: minor additions

- added rve_has_side_effects(), preliminary version
 (for now is equivalent with !rve_is_constant())
- exported rve_destroy()
Andrei Pelinescu-Onciul 16 سال پیش
والد
کامیت
2d66865195
2فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 11 0
      rvalue.c
  2. 4 0
      rvalue.h

+ 11 - 0
rvalue.c

@@ -452,6 +452,17 @@ int rve_is_constant(struct rval_expr* rve)
 
 
 
+/** returns true if the expression has side-effects.
+  * @return  1 for possible side-effects, 0 for no side-effects
+  * TODO: add better checks
+  */
+int rve_has_side_effects(struct rval_expr* rve)
+{
+	return !rve_is_constant(rve);
+}
+
+
+
 /** returns true if operator is unary (takes only 1 arg).
   * @return 0 or 1 on
   */

+ 4 - 0
rvalue.h

@@ -188,6 +188,8 @@ int rval_expr_eval_rvint( struct run_act_ctx* h, struct sip_msg* msg,
 enum rval_type rve_guess_type(struct rval_expr* rve);
 /** returns true if expression is constant. */
 int rve_is_constant(struct rval_expr* rve);
+/** returns true if the expression can have side-effect */
+int rve_has_side_effects(struct rval_expr* rve);
 /** returns 1 if expression is valid (type-wise).*/
 int rve_check_type(enum rval_type* type, struct rval_expr* rve,
 					struct rval_expr** bad_rve, enum rval_type* bad_type,
@@ -206,6 +208,8 @@ struct rval_expr* mk_rval_expr1(enum rval_expr_op op, struct rval_expr* rve1,
 struct rval_expr* mk_rval_expr2(enum rval_expr_op op, struct rval_expr* rve1,
 													  struct rval_expr* rve2,
 													  struct cfg_pos* pos);
+/** destroys a pkg_malloc'ed rve. */
+void rve_destroy(struct rval_expr* rve);
 
 /** fix a rval_expr. */
 int fix_rval_expr(void** p);