From 57f56f53a674531762add4c20b82515a65077ed0 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 25 Mar 2016 15:40:21 +0100 Subject: [PATCH] struct variable, #14/18, introduce `var_alloc_xxx()' --- src/frontend/variable.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/frontend/variable.h | 6 ++++++ 2 files changed, 46 insertions(+) diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 00773af36..c842660f6 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -974,6 +974,46 @@ var_alloc(char *name, struct variable *next) return v; } +struct variable * +var_alloc_bool(char *name, bool value, struct variable *next) +{ + struct variable *v = var_alloc(name, next); + var_set_bool(v, value); + return v; +} + +struct variable * +var_alloc_num(char *name, int value, struct variable *next) +{ + struct variable *v = var_alloc(name, next); + var_set_num(v, value); + return v; +} + +struct variable * +var_alloc_real(char *name, double value, struct variable *next) +{ + struct variable *v = var_alloc(name, next); + var_set_real(v, value); + return v; +} + +struct variable * +var_alloc_string(char *name, char * value, struct variable *next) +{ + struct variable *v = var_alloc(name, next); + var_set_string(v, value); + return v; +} + +struct variable * +var_alloc_vlist(char *name, struct variable * value, struct variable *next) +{ + struct variable *v = var_alloc(name, next); + var_set_vlist(v, value); + return v; +} + void var_set_bool(struct variable *v, bool value) { diff --git a/src/frontend/variable.h b/src/frontend/variable.h index f7c15dcce..e6f179135 100644 --- a/src/frontend/variable.h +++ b/src/frontend/variable.h @@ -45,6 +45,12 @@ void free_struct_variable(struct variable *v); struct variable *var_alloc(char *name, struct variable *next); +struct variable *var_alloc_bool(char *name, bool, struct variable *next); +struct variable *var_alloc_num(char *name, int, struct variable *next); +struct variable *var_alloc_real(char *name, double, struct variable *next); +struct variable *var_alloc_string(char *name, char *, struct variable *next); +struct variable *var_alloc_vlist(char *name, struct variable *, struct variable *next); + void var_set_bool(struct variable *, bool); void var_set_num(struct variable *, int); void var_set_real(struct variable *, double);