firfilt: simplifying copy() method
@@ -299,7 +299,9 @@ FIRFILT() FIRFILT(_copy)(FIRFILT() q_orig)
// create filter object and copy base parameters
FIRFILT() q_copy = (FIRFILT()) malloc(sizeof(struct FIRFILT(_s)));
- q_copy->h_len = q_orig->h_len;
+ memmove(q_copy, q_orig, sizeof(struct FIRFILT(_s)));
+
+ // copy filter coefficients
q_copy->h = (TC *) malloc((q_orig->h_len)*sizeof(TC));
memmove(q_copy->h, q_orig->h, (q_orig->h_len)*sizeof(TC));
@@ -308,15 +310,12 @@ FIRFILT() FIRFILT(_copy)(FIRFILT() q_orig)
q_copy->w = WINDOW(_copy)(q_orig->w);
#else
// initialize array for buffering
- q_copy->w_len = q_orig->w_len;
- q_copy->w_mask = q_orig->w_mask;
- q_copy->w = q_orig->w;
- q_copy->w_index = q_orig->w_index;
+ q_copy->w = (TI *) malloc((q_orig->w_len)*sizeof(TI));
+ memmove(q_copy->w, q_orig->w, (q_orig->w_len)*sizeof(TI));
#endif
- // copy dot product object and scale
+ // copy dot product object and return
q_copy->dp = DOTPROD(_copy)(q_orig->dp);
- q_copy->scale = q_orig->scale;
return q_copy;
}
