release_sample_expr(rule->arg.timeout.expr);
}
+struct act_rule *new_act_rule(enum act_from from, const char *file, int linenum);
void free_act_rules(struct list *rules);
#endif /* _HAPROXY_ACTION_H */
return best_ptr;
}
+/* allocates a rule for ruleset <from> (ACT_F_*), from file name <file> and
+ * line <linenum>. <file> and <linenum> may be zero if unknown. Returns the
+ * rule, otherwise NULL in case of memory allocation error.
+ */
+struct act_rule *new_act_rule(enum act_from from, const char *file, int linenum)
+{
+ struct act_rule *rule;
+
+ rule = calloc(1, sizeof(*rule));
+ if (!rule)
+ return NULL;
+ rule->from = from;
+ return rule;
+}
+
void free_act_rules(struct list *rules)
{
struct act_rule *rule, *ruleb;
const struct action_kw *custom = NULL;
int cur_arg;
- rule = calloc(1, sizeof(*rule));
+ rule = new_act_rule(ACT_F_HTTP_REQ, file, linenum);
if (!rule) {
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
goto out_err;
}
- rule->from = ACT_F_HTTP_REQ;
if (((custom = action_http_req_custom(args[0])) != NULL)) {
char *errmsg = NULL;
const struct action_kw *custom = NULL;
int cur_arg;
- rule = calloc(1, sizeof(*rule));
+ rule = new_act_rule(ACT_F_HTTP_RES, file, linenum);
if (!rule) {
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
goto out_err;
}
- rule->from = ACT_F_HTTP_RES;
if (((custom = action_http_res_custom(args[0])) != NULL)) {
char *errmsg = NULL;
const struct action_kw *custom = NULL;
int cur_arg;
- rule = calloc(1, sizeof(*rule));
+ rule = new_act_rule(ACT_F_HTTP_RES, file, linenum);
if (!rule) {
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
goto out_err;
}
- rule->from = ACT_F_HTTP_RES;
if (((custom = action_http_after_res_custom(args[0])) != NULL)) {
char *errmsg = NULL;
return 0;
}
- rule = calloc(1, sizeof(*rule));
+ rule = new_act_rule(ACT_F_TCP_RES_CNT, file, line);
if (!rule) {
memprintf(err, "parsing [%s:%d] : out of memory", file, line);
return -1;
where |= SMP_VAL_FE_RES_CNT;
if (curpx->cap & PR_CAP_BE)
where |= SMP_VAL_BE_RES_CNT;
- rule->from = ACT_F_TCP_RES_CNT;
if (tcp_parse_response_rule(args, arg, section_type, curpx, defpx, rule, err, where, file, line) < 0)
goto error;
return 0;
}
- rule = calloc(1, sizeof(*rule));
+ rule = new_act_rule(0, file, line);
if (!rule) {
memprintf(err, "parsing [%s:%d] : out of memory", file, line);
return -1;
struct tcpcheck_rule *chk = NULL;
struct act_rule *actrule = NULL;
- actrule = calloc(1, sizeof(*actrule));
+ actrule = new_act_rule(ACT_F_TCP_CHK, file, line);
if (!actrule) {
memprintf(errmsg, "out of memory");
goto error;
}
actrule->kw = kw;
- actrule->from = ACT_F_TCP_CHK;
cur_arg++;
if (kw->parse((const char **)args, &cur_arg, px, actrule, errmsg) == ACT_RET_PRS_ERR) {