From 30becb45099f4c4cbb9c5047759eb52162e1695e Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 22 Dec 2015 17:31:44 +0100 Subject: [PATCH] frontend/vectors.c, vec_get(), #2/2 rewrite --- src/frontend/vectors.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index 5b6d0ee7f..95273c3e1 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -574,18 +574,18 @@ vec_get(const char *vec_name) * used with the parameters of isrc and vsrc */ struct variable *nv; - double *list; - list = TMALLOC(double, 1); - nv = vv->va_vlist; - for (i = 1; ; i++) { - list = TREALLOC(double, list, i); - list[i-1] = nv->va_real; - nv = nv->va_next; - if (!nv) - break; - } - d->v_realdata = list; + + i = 0; + for (nv = vv->va_vlist; nv; nv = nv->va_next) + i++; + + d->v_realdata = TREALLOC(double, d->v_realdata, i); d->v_length = i; + + i = 0; + for (nv = vv->va_vlist; nv; nv = nv->va_next) + d->v_realdata[i++] = nv->va_real; + /* To be able to identify the vector to represent * belongs to a special "conunto" and should be printed in a * special way.