Browse Source

dvec abstraction, #4/11, emphasise `ZERO(dvec)' initialisation

pre-master-46
rlar 10 years ago
parent
commit
8a4a37b5bb
  1. 1
      src/frontend/com_compose.c
  2. 4
      src/frontend/com_fft.c
  3. 1
      src/frontend/com_let.c
  4. 1
      src/frontend/define.c
  5. 5
      src/frontend/dvec.c
  6. 4
      src/frontend/evaluate.c
  7. 1
      src/frontend/fourier.c
  8. 2
      src/frontend/parse.c
  9. 1
      src/frontend/rawfile.c
  10. 3
      src/frontend/spec.c
  11. 2
      src/frontend/vectors.c
  12. 2
      src/maths/cmaths/cmath4.c

1
src/frontend/com_compose.c

@ -452,7 +452,6 @@ com_compose(wordlist *wl)
} }
result = dvec_alloc(); result = dvec_alloc();
ZERO(result, struct dvec);
result->v_name = resname; result->v_name = resname;
result->v_type = type; result->v_type = type;

4
src/frontend/com_fft.c

@ -129,7 +129,6 @@ com_fft(wordlist *wl)
plot_cur->pl_date = copy(datestring()); plot_cur->pl_date = copy(datestring());
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = copy("frequency"); f->v_name = copy("frequency");
f->v_type = SV_FREQUENCY; f->v_type = SV_FREQUENCY;
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT); f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
@ -150,7 +149,6 @@ com_fft(wordlist *wl)
for (i = 0, vec = vlist; i<ngood; i++) { for (i = 0, vec = vlist; i<ngood; i++) {
tdvec[i] = vec->v_realdata; /* real input data */ tdvec[i] = vec->v_realdata; /* real input data */
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = vec_basename(vec); f->v_name = vec_basename(vec);
f->v_type = SV_NOTYPE; f->v_type = SV_NOTYPE;
f->v_flags = (VF_COMPLEX | VF_PERMANENT); f->v_flags = (VF_COMPLEX | VF_PERMANENT);
@ -355,7 +353,6 @@ com_psd(wordlist *wl)
plot_cur->pl_date = copy(datestring()); plot_cur->pl_date = copy(datestring());
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = copy("frequency"); f->v_name = copy("frequency");
f->v_type = SV_FREQUENCY; f->v_type = SV_FREQUENCY;
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT); f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
@ -377,7 +374,6 @@ com_psd(wordlist *wl)
for (i = 0, vec = vlist; i<ngood; i++) { for (i = 0, vec = vlist; i<ngood; i++) {
tdvec[i] = vec->v_realdata; /* real input data */ tdvec[i] = vec->v_realdata; /* real input data */
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = vec_basename(vec); f->v_name = vec_basename(vec);
f->v_type = SV_NOTYPE; //vec->v_type; f->v_type = SV_NOTYPE; //vec->v_type;
f->v_flags = (VF_COMPLEX | VF_PERMANENT); f->v_flags = (VF_COMPLEX | VF_PERMANENT);

1
src/frontend/com_let.c

@ -162,7 +162,6 @@ com_let(wordlist *wl)
/* create and assign a new vector */ /* create and assign a new vector */
n = dvec_alloc(); n = dvec_alloc();
ZERO(n, struct dvec);
n->v_name = copy(p); n->v_name = copy(p);
n->v_type = t->v_type; n->v_type = t->v_type;
n->v_flags = (t->v_flags | VF_PERMANENT); n->v_flags = (t->v_flags | VF_PERMANENT);

1
src/frontend/define.c

@ -162,7 +162,6 @@ savetree(struct pnode *pn)
d = pn->pn_value; d = pn->pn_value;
if ((d->v_length != 0) || eq(d->v_name, "list")) { if ((d->v_length != 0) || eq(d->v_name, "list")) {
pn->pn_value = dvec_alloc(); pn->pn_value = dvec_alloc();
ZERO(pn->pn_value, struct dvec);
pn->pn_value->v_name = copy(d->v_name); pn->pn_value->v_name = copy(d->v_name);
pn->pn_value->v_length = d->v_length; pn->pn_value->v_length = d->v_length;
pn->pn_value->v_type = d->v_type; pn->pn_value->v_type = d->v_type;

5
src/frontend/dvec.c

@ -7,5 +7,10 @@ dvec_alloc(void)
{ {
struct dvec *rv = TMALLOC(struct dvec, 1); struct dvec *rv = TMALLOC(struct dvec, 1);
if (!rv)
return NULL;
ZERO(rv, struct dvec);
return rv; return rv;
} }

4
src/frontend/evaluate.c

@ -319,7 +319,6 @@ doop(char what,
return (NULL); return (NULL);
/* Make up the new vector. */ /* Make up the new vector. */
res = dvec_alloc(); res = dvec_alloc();
ZERO(res, struct dvec);
if (relflag || (isreal(v1) && isreal(v2) && (func != cx_comma))) { if (relflag || (isreal(v1) && isreal(v2) && (func != cx_comma))) {
res->v_type = SV_NOTYPE; res->v_type = SV_NOTYPE;
res->v_flags = (v1->v_flags | v2->v_flags | res->v_flags = (v1->v_flags | v2->v_flags |
@ -616,7 +615,6 @@ op_range(struct pnode *arg1, struct pnode *arg2)
} }
res = dvec_alloc(); res = dvec_alloc();
ZERO(res, struct dvec);
res->v_name = mkcname('R', v->v_name, ind->v_name); res->v_name = mkcname('R', v->v_name, ind->v_name);
res->v_type = v->v_type; res->v_type = v->v_type;
res->v_flags = v->v_flags; res->v_flags = v->v_flags;
@ -772,7 +770,6 @@ op_ind(struct pnode *arg1, struct pnode *arg2)
/* Make up the new vector. */ /* Make up the new vector. */
res = dvec_alloc(); res = dvec_alloc();
ZERO(res, struct dvec);
res->v_name = mkcname('[', v->v_name, ind->v_name); res->v_name = mkcname('[', v->v_name, ind->v_name);
res->v_type = v->v_type; res->v_type = v->v_type;
res->v_flags = v->v_flags; res->v_flags = v->v_flags;
@ -942,7 +939,6 @@ apply_func(struct func *func, struct pnode *arg)
name = mkcname('b', v->v_name, NULL); name = mkcname('b', v->v_name, NULL);
t = dvec_alloc(); t = dvec_alloc();
ZERO(t, struct dvec);
t->v_name = name; t->v_name = name;
t->v_flags = (v->v_flags & ~VF_COMPLEX & ~VF_REAL & t->v_flags = (v->v_flags & ~VF_COMPLEX & ~VF_REAL &

1
src/frontend/fourier.c

@ -193,7 +193,6 @@ fourier(wordlist *wl, struct plot *current_plot)
/* with size 3 * nfreqs in current plot */ /* with size 3 * nfreqs in current plot */
/* generate name for new vector, using vec->name */ /* generate name for new vector, using vec->name */
n = dvec_alloc(); n = dvec_alloc();
ZERO(n, struct dvec);
n->v_name = tprintf("fourier%d%d", callstof, newveccount); n->v_name = tprintf("fourier%d%d", callstof, newveccount);
n->v_type = SV_NOTYPE; n->v_type = SV_NOTYPE;

2
src/frontend/parse.c

@ -331,7 +331,6 @@ PP_mknnode(double number)
struct dvec *v; struct dvec *v;
v = dvec_alloc(); v = dvec_alloc();
ZERO(v, struct dvec);
/* We don't use printnum because it screws up PP_mkfnode above. We have /* We don't use printnum because it screws up PP_mkfnode above. We have
* to be careful to deal properly with node numbers that are quite * to be careful to deal properly with node numbers that are quite
@ -369,7 +368,6 @@ PP_mksnode(const char *string)
v = vec_get(string); v = vec_get(string);
if (v == NULL) { if (v == NULL) {
nv = dvec_alloc(); nv = dvec_alloc();
ZERO(nv, struct dvec);
nv->v_name = copy(string); nv->v_name = copy(string);
p->pn_value = nv; p->pn_value = nv;
return (p); return (p);

1
src/frontend/rawfile.c

@ -469,7 +469,6 @@ raw_read(char *name) {
* be dangerous if the file is invalid. * be dangerous if the file is invalid.
*/ */
v = dvec_alloc(); v = dvec_alloc();
ZERO(v, struct dvec);
v->v_type = SV_NOTYPE; v->v_type = SV_NOTYPE;
v->v_flags = (short)flags; v->v_flags = (short)flags;
v->v_length = npoints; v->v_length = npoints;

3
src/frontend/spec.c

@ -208,7 +208,6 @@ com_spec(wordlist *wl)
plot_cur->pl_date = copy(datestring()); plot_cur->pl_date = copy(datestring());
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = copy("frequency"); f->v_name = copy("frequency");
f->v_type = SV_FREQUENCY; f->v_type = SV_FREQUENCY;
f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT); f->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
@ -222,7 +221,6 @@ com_spec(wordlist *wl)
for (i = 0, vec = vlist; i < ngood; i++) { for (i = 0, vec = vlist; i < ngood; i++) {
tdvec[i] = vec->v_realdata; tdvec[i] = vec->v_realdata;
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = vec_basename(vec); f->v_name = vec_basename(vec);
f->v_type = vec->v_type; f->v_type = vec->v_type;
f->v_flags = (VF_COMPLEX | VF_PERMANENT); f->v_flags = (VF_COMPLEX | VF_PERMANENT);
@ -282,7 +280,6 @@ com_spec(wordlist *wl)
#ifdef KEEPWINDOW #ifdef KEEPWINDOW
f = dvec_alloc(); f = dvec_alloc();
ZERO(f, struct dvec);
f->v_name = copy("win"); f->v_name = copy("win");
f->v_type = SV_NOTYPE; f->v_type = SV_NOTYPE;
f->v_flags = (VF_REAL | VF_PERMANENT); f->v_flags = (VF_REAL | VF_PERMANENT);

2
src/frontend/vectors.c

@ -523,7 +523,6 @@ vec_get(const char *vec_name)
} }
d = dvec_alloc(); d = dvec_alloc();
ZERO(d, struct dvec);
d->v_name = copy(whole); /* MW. The same as word before */ d->v_name = copy(whole); /* MW. The same as word before */
d->v_type = SV_NOTYPE; d->v_type = SV_NOTYPE;
d->v_flags |= VF_REAL; /* No complex values yet... */ d->v_flags |= VF_REAL; /* No complex values yet... */
@ -1123,7 +1122,6 @@ vec_mkfamily(struct dvec *v)
indexstring(count, v->v_numdims - 1, buf2); indexstring(count, v->v_numdims - 1, buf2);
d = dvec_alloc(); d = dvec_alloc();
ZERO(d, struct dvec);
d->v_name = tprintf("%s%s", v->v_name, buf2); d->v_name = tprintf("%s%s", v->v_name, buf2);
d->v_type = v->v_type; d->v_type = v->v_type;

2
src/maths/cmaths/cmath4.c

@ -627,7 +627,6 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
/* create a new scale vector */ /* create a new scale vector */
sv = dvec_alloc(); sv = dvec_alloc();
ZERO(sv, struct dvec);
sv->v_name = copy("fft_scale"); sv->v_name = copy("fft_scale");
sv->v_type = SV_FREQUENCY; sv->v_type = SV_FREQUENCY;
sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT); sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);
@ -864,7 +863,6 @@ cx_ifft(void *data, short int type, int length, int *newlength, short int *newty
/* create a new scale vector */ /* create a new scale vector */
sv = dvec_alloc(); sv = dvec_alloc();
ZERO(sv, struct dvec);
sv->v_name = copy("ifft_scale"); sv->v_name = copy("ifft_scale");
sv->v_type = SV_TIME; sv->v_type = SV_TIME;
sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT); sv->v_flags = (VF_REAL | VF_PERMANENT | VF_PRINT);

Loading…
Cancel
Save