dvec abstraction, #10/11, introduce `dvec_trunc()'

This commit is contained in:
rlar 2015-12-28 20:28:39 +01:00
parent 3962453739
commit c2a7821449
4 changed files with 11 additions and 3 deletions

View File

@ -40,6 +40,13 @@ dvec_alloc(char *name, int type, short flags, int length, void *storage)
}
void
dvec_trunc(struct dvec *v, int length)
{
v->v_length = length;
}
void
dvec_free(struct dvec *v)
{

View File

@ -90,7 +90,7 @@ xtend(struct dvec *v, int length)
return;
if (v->v_length > length) {
v->v_length = length;
dvec_trunc(v, length);
return;
}
@ -158,7 +158,7 @@ compress(struct dvec *d, double *xcomp, double *xind)
d->v_realdata[i] = d->v_realdata[i * cfac];
else
d->v_compdata[i] = d->v_compdata[i * cfac];
d->v_length = i;
dvec_trunc(d, i);
}
}
}

View File

@ -695,7 +695,7 @@ fixdims(struct dvec *v, char *s)
ndimpoints *= v->v_dims[i];
if (v->v_length >= ndimpoints)
v->v_length = ndimpoints;
dvec_trunc(v, ndimpoints);
else
v->v_numdims = 0;
}

View File

@ -69,6 +69,7 @@ struct dveclist {
};
struct dvec *dvec_alloc(char *name, int type, short flags, int length, void *storage);
void dvec_trunc(struct dvec *v, int length);
void dvec_free(struct dvec *);
#endif