From 7b08dbbbe9a3dbe326a751497d27b9e187142eb8 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 27 Feb 2018 23:49:27 -0500 Subject: stable for calculator --- variable.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index bcf96cb..8b7dc12 100644 --- a/variable.c +++ b/variable.c @@ -37,7 +37,6 @@ variable *vmake(uint8_t fromc, uint8_t valtype, void *value) v->svalue = 0; switch (valtype) { case STRING: - v->value = 0; v->svalue = fixstring(value); free(value); break; @@ -50,7 +49,6 @@ variable *vmake(uint8_t fromc, uint8_t valtype, void *value) v->svalue = str_func; break; case EXPR: - v->value = 0; v->svalue = value; break; } @@ -71,15 +69,15 @@ variable *vmakef(float value) void fsetstr(variable *f) { if (f->svalue == 0 || f->svalue == str_undef) - f->svalue = (char *)malloc(16); - snprintf(f->svalue, 16, "%f", FLOAT(f)); + f->svalue = (char *)malloc(32); + snprintf(f->svalue, 32, "%f", FLOAT(f)); } void isetstr(variable *i) { if (i->svalue == 0 || i->svalue == str_undef) - i->svalue = (char *)malloc(12); - snprintf(i->svalue, 12, "%d", (int)INT(i)); + i->svalue = (char *)malloc(32); + snprintf(i->svalue, 32, "%d", (int)INT(i)); } variable *itostring(variable *v) -- cgit v1.2.3