MEDIUM: sample: pass an empty list instead of a null for fetch args
ACL and sample fetches use args list and it is really not convenient to
check for null args everywhere. Now for empty args we pass a constant
list of end of lists. It will allow us to remove many useless checks.
diff --git a/src/sample.c b/src/sample.c
index 3e0c965..3eef4c3 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -320,6 +320,7 @@
LIST_INIT(&(expr->conv_exprs));
expr->fetch = fetch;
+ expr->arg_p = empty_arg_list;
if (end != endw) {
char *err_msg = NULL;
@@ -344,6 +345,9 @@
goto out_error;
}
+ if (!expr->arg_p)
+ expr->arg_p = empty_arg_list;
+
if (fetch->val_args && !fetch->val_args(expr->arg_p, &err_msg)) {
p = my_strndup(str[*idx], endw - str[*idx]);
if (p) {
@@ -436,6 +440,9 @@
goto out_error;
}
+ if (!conv_expr->arg_p)
+ conv_expr->arg_p = empty_arg_list;
+
if (conv->val_args && !conv->val_args(conv_expr->arg_p, &err_msg)) {
p = my_strndup(str[*idx], endw - str[*idx]);
if (p) {