1 /* This file is modified by I.Dricker I.dricker@isti.com for version 3.2.17 of evalresp*/
2 #ifdef HAVE_CONFIG_H
3 #include <config.h>
4 #endif
5
6
7 #ifdef HAVE_MALLOC_H
8 #include <malloc.h>
9 #endif
10
11 #include "./evresp.h"
12
13 #include <stdlib.h>
14
15 #include <string.h>
16
17
18 /* alloc_complex: allocates space for an array of complex numbers, returns a pointer to that
19 array (exits with error if fails) */
20
alloc_complex(int npts)21 struct complex *alloc_complex(int npts)
22 {
23 struct complex *cptr;
24
25 if(npts) {
26 if((cptr = (struct complex *) malloc(npts*sizeof(struct complex)))
27 == (struct complex *)NULL) {
28 error_exit(OUT_OF_MEMORY,"alloc_complex; malloc() failed for (complex) vector");
29 }
30 }
31 else
32 cptr = (struct complex *)NULL;
33
34 return(cptr);
35 }
36
37 /* alloc_string_array: allocates space for an array of strings, returns a
38 pointer to that array (exits with error if fails) */
39
alloc_string_array(int nstrings)40 struct string_array *alloc_string_array(int nstrings)
41 {
42 struct string_array *sl_ptr;
43 int i;
44
45 if(nstrings) {
46 if((sl_ptr = (struct string_array *) malloc(sizeof(struct string_array)))
47 == (struct string_array *)NULL) {
48 error_exit(OUT_OF_MEMORY,"alloc_string_array; malloc() failed for (string_array)");
49 }
50 if((sl_ptr->strings = (char **) malloc(nstrings*sizeof(char *))) == (char **)NULL) {
51 error_exit(OUT_OF_MEMORY,"alloc_string_array; malloc() failed for (char *) vector");
52 }
53 for(i = 0; i < nstrings; i++)
54 sl_ptr->strings[i] = (char *)NULL;
55 sl_ptr->nstrings = nstrings;
56 }
57 else
58 sl_ptr = (struct string_array *)NULL;
59
60 return(sl_ptr);
61 }
62
63 /* alloc_scn: allocates space for a station-channel structure, returns a
64 pointer to that structure (exits with error if fails) */
65
alloc_scn()66 struct scn *alloc_scn()
67 {
68 struct scn *scn_ptr;
69
70
71 if((scn_ptr = (struct scn *) malloc(sizeof(struct scn)))
72 == (struct scn *)NULL) {
73 error_exit(OUT_OF_MEMORY,"alloc_scn; malloc() failed for (scn)");
74 }
75 if((scn_ptr->station = (char *) malloc(STALEN*sizeof(char))) == (char *)NULL) {
76 error_exit(OUT_OF_MEMORY,"alloc_scn; malloc() failed for (station)");
77 }
78 if((scn_ptr->network = (char *) malloc(NETLEN*sizeof(char))) == (char *)NULL) {
79 error_exit(OUT_OF_MEMORY,"alloc_scn; malloc() failed for (station)");
80 }
81 if((scn_ptr->locid = (char *) malloc(LOCIDLEN*sizeof(char))) == (char *)NULL) {
82 error_exit(OUT_OF_MEMORY,"alloc_scn; malloc() failed for (channel)");
83 }
84 if((scn_ptr->channel = (char *) malloc(CHALEN*sizeof(char))) == (char *)NULL) {
85 error_exit(OUT_OF_MEMORY,"alloc_scn; malloc() failed for (channel)");
86 }
87
88 strncpy(scn_ptr->station,"",STALEN);
89 strncpy(scn_ptr->network,"",NETLEN);
90 strncpy(scn_ptr->locid,"",LOCIDLEN);
91 strncpy(scn_ptr->channel,"",CHALEN);
92 scn_ptr->found = 0;
93
94 return(scn_ptr);
95 }
96
97 /* alloc_response: allocates space for an array of responses, returns a pointer to that
98 array (exits with error if fails). A 'response' is a combination
99 of a complex array, a station-channel-network, and a pointer to the
100 next 'response' in the list */
101
alloc_response(int npts)102 struct response *alloc_response(int npts)
103 {
104 struct response *rptr;
105 struct complex *cvec;
106 int k;
107
108 if(npts) {
109 if((rptr = (struct response *) malloc(sizeof(struct response)))
110 == (struct response *)NULL) {
111 error_exit(OUT_OF_MEMORY,"alloc_response; malloc() failed for (response) vector");
112 }
113 strncpy(rptr->station,"",STALEN);
114 strncpy(rptr->locid,"",LOCIDLEN);
115 strncpy(rptr->channel,"",NETLEN);
116 strncpy(rptr->network,"",CHALEN);
117 rptr->rvec = alloc_complex(npts);
118 cvec = rptr->rvec;
119 for(k = 0; k < npts; k++) {
120 cvec[k].real = 0.0;
121 cvec[k].imag = 0.0;
122 }
123 rptr->next = (struct response *)NULL;
124 /*IGD add freqs to this structure to process blockette 55 */
125 rptr->nfreqs = 0;
126 rptr->freqs = (double *) NULL;
127 }
128 else
129 rptr = (struct response *)NULL;
130
131 return(rptr);
132 }
133
134 /* alloc_scn_list: allocates space for an array of station/channel pairs,
135 returns a pointer to that array (exits with error if
136 fails) */
137
alloc_scn_list(int nscn)138 struct scn_list *alloc_scn_list(int nscn)
139 {
140 struct scn_list *sc_ptr;
141 int i;
142
143 if(nscn) {
144 if((sc_ptr = (struct scn_list *) malloc(sizeof(struct scn_list)))
145 == (struct scn_list *)NULL) {
146 error_exit(OUT_OF_MEMORY,"alloc_scn_list; malloc() failed for (scn_list)");
147 }
148 if((sc_ptr->scn_vec = (struct scn **) malloc(nscn*sizeof(struct scn *)))
149 == (struct scn **)NULL) {
150 error_exit(OUT_OF_MEMORY,"alloc_scn_list; malloc() failed for (scn_vec)");
151 }
152 for(i = 0; i < nscn; i++)
153 sc_ptr->scn_vec[i] = alloc_scn();
154 sc_ptr->nscn = nscn;
155 }
156 else
157 sc_ptr = (struct scn_list *)NULL;
158
159 return(sc_ptr);
160 }
161
162 /* alloc_file_list: allocates space for an element of a linked list of
163 filenames, returns a pointer to that structure
164 (exits with error if fails) */
165
alloc_file_list()166 struct file_list *alloc_file_list()
167 {
168 struct file_list *flst_ptr;
169
170
171 if((flst_ptr = (struct file_list *) malloc(sizeof(struct file_list)))
172 == (struct file_list *)NULL) {
173 error_exit(OUT_OF_MEMORY,"alloc_file_list; malloc() failed for (file_list)");
174 }
175 flst_ptr->name = (char *)NULL;
176 flst_ptr->next_file = (struct file_list *)NULL;
177
178 return(flst_ptr);
179 }
180
181 /* alloc_matched_files: allocates space for an element of a linked list of
182 matching files, returns a pointer to that structure
183 (exits with error if fails) */
184
alloc_matched_files()185 struct matched_files *alloc_matched_files()
186 {
187 struct matched_files *flst_ptr;
188
189
190 if((flst_ptr = (struct matched_files *) malloc(sizeof(struct matched_files)))
191 == (struct matched_files *)NULL) {
192 error_exit(OUT_OF_MEMORY,"alloc_matched_files; malloc() failed for (matched_files)");
193 }
194 flst_ptr->nfiles = 0;
195 flst_ptr->first_list = (struct file_list *)NULL;
196 flst_ptr->ptr_next = (struct matched_files *)NULL;
197
198 return(flst_ptr);
199 }
200
201 /* alloc_double: allocates space for an array of double precision numbers, returns a pointer to
202 that array (exits with error if fails) */
203
alloc_double(int npts)204 double *alloc_double(int npts)
205 {
206 double *dptr;
207
208 if(npts) {
209 if((dptr = (double *) malloc(npts*sizeof(double))) == (double *)NULL) {
210 error_exit(OUT_OF_MEMORY,"alloc_double; malloc() failed for (double) vector");
211 }
212 }
213 else
214 dptr = (double *)NULL;
215
216 return(dptr);
217 }
218
219 /* alloc_char: allocates space for an array of characters, returns a pointer to
220 that array (exits with error if fails) */
221
alloc_char(int len)222 char *alloc_char(int len)
223 {
224 char *cptr;
225
226 if(len) {
227 if((cptr = (char *) malloc(len*sizeof(char))) == (char *)NULL) {
228 error_exit(OUT_OF_MEMORY,"alloc_char; malloc() failed for (char) vector");
229 }
230 }
231 else
232 cptr = (char *)NULL;
233
234 return(cptr);
235 }
236
237 /* alloc_char_ptr: allocates space for an array of char pointers, returns a
238 pointer to that array (exits with error if fails) */
239
alloc_char_ptr(int len)240 char **alloc_char_ptr(int len)
241 {
242 char **cptr;
243
244 if(len) {
245 if((cptr = (char **) malloc(len*sizeof(char *))) == (char **)NULL) {
246 error_exit(OUT_OF_MEMORY,"alloc_char_ptr; malloc() failed for (char *) vector");
247 }
248 }
249 else
250 cptr = (char **)NULL;
251
252 return(cptr);
253 }
254
255 /* alloc_pz: allocates space for a pole-zero type filter structure and returns a pointer to that
256 structure.
257 Note: the space for the complex poles and zeros is not allocated here, the space
258 for these vectors must be allocated as they are read, since the number of
259 poles and zeros is unknown until the blockette is partially parsed. */
260
alloc_pz()261 struct blkt *alloc_pz()
262 {
263 struct blkt *blkt_ptr;
264
265 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
266 == (struct blkt *)NULL) {
267 error_exit(OUT_OF_MEMORY,"alloc_pz; malloc() failed for (Poles & Zeros) blkt structure");
268 }
269
270 blkt_ptr->type = 0;
271 blkt_ptr->next_blkt = (struct blkt *)NULL;
272 blkt_ptr->blkt_info.pole_zero.zeros = (struct complex *)NULL;
273 blkt_ptr->blkt_info.pole_zero.poles = (struct complex *)NULL;
274 blkt_ptr->blkt_info.pole_zero.nzeros = 0;
275 blkt_ptr->blkt_info.pole_zero.npoles = 0;
276
277 return(blkt_ptr);
278 }
279
280 /* alloc_coeff: allocates space for a coefficients-type filter
281 Note: see alloc_pz for details (like alloc_pz, this does not allocate space for
282 the numerators and denominators, that is left until parse_fir()) */
283
alloc_coeff()284 struct blkt *alloc_coeff()
285 {
286 struct blkt *blkt_ptr;
287
288 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
289 == (struct blkt *)NULL) {
290 error_exit(OUT_OF_MEMORY,"alloc_coeff; malloc() failed for (FIR) blkt structure");
291 }
292
293 blkt_ptr->type = 0;
294 blkt_ptr->next_blkt = (struct blkt *)NULL;
295 blkt_ptr->blkt_info.coeff.numer = (double *)NULL;
296 blkt_ptr->blkt_info.coeff.denom = (double *)NULL;
297 blkt_ptr->blkt_info.coeff.nnumer = 0;
298 blkt_ptr->blkt_info.coeff.ndenom = 0;
299 blkt_ptr->blkt_info.coeff.h0 = 1.0; /*IGD this field is new for v 3.2.17*/
300
301 return(blkt_ptr);
302 }
303
304 /* alloc_fir: allocates space for a fir-type filter
305 Note: see alloc_pz for details (like alloc_pz, this does not allocate space for
306 the numerators and denominators, that is left until parse_fir()) */
307
alloc_fir()308 struct blkt *alloc_fir()
309 {
310 struct blkt *blkt_ptr;
311
312 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
313 == (struct blkt *)NULL) {
314 error_exit(OUT_OF_MEMORY,"alloc_fir; malloc() failed for (FIR) blkt structure");
315 }
316
317 blkt_ptr->type = 0;
318 blkt_ptr->next_blkt = (struct blkt *)NULL;
319 blkt_ptr->blkt_info.fir.coeffs = (double *)NULL;
320 blkt_ptr->blkt_info.fir.ncoeffs = 0;
321 blkt_ptr->blkt_info.fir.h0 = 1.0;
322
323 return(blkt_ptr);
324 }
325
326 /* alloc_ref: allocates space for a response reference type filter structure and returns a pointer
327 to that structure. */
328
alloc_ref()329 struct blkt *alloc_ref()
330 {
331 struct blkt *blkt_ptr;
332
333 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
334 == (struct blkt *)NULL) {
335 error_exit(OUT_OF_MEMORY,"alloc_ref; malloc() failed for (Resp. Ref.) blkt structure");
336 }
337
338 blkt_ptr->type = REFERENCE;
339 blkt_ptr->next_blkt = (struct blkt *)NULL;
340 blkt_ptr->blkt_info.reference.num_stages = 0;
341 blkt_ptr->blkt_info.reference.stage_num = 0;
342 blkt_ptr->blkt_info.reference.num_responses = 0;
343
344 return(blkt_ptr);
345 }
346
347 /* alloc_gain: allocates space for a gain type filter structure and returns a pointer to that
348 structure.
349 Note: the space for the calibration vectors is not allocated here, the space
350 for these vectors must be allocated as they are read, since the number of
351 calibration points is unknown until the blockette is partially parsed. */
352
alloc_gain()353 struct blkt *alloc_gain()
354 {
355 struct blkt *blkt_ptr;
356
357 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
358 == (struct blkt *)NULL) {
359 error_exit(OUT_OF_MEMORY,"alloc_gain; malloc() failed for (Gain) blkt structure");
360 }
361
362 blkt_ptr->type = GAIN;
363 blkt_ptr->next_blkt = (struct blkt *)NULL;
364 blkt_ptr->blkt_info.gain.gain = 0;
365 blkt_ptr->blkt_info.gain.gain_freq = 0;
366
367 return(blkt_ptr);
368 }
369
370 /* alloc_list: allocates space for a list type filter structure and returns a pointer to that
371 structure.
372 Note: the space for the amplitude, phase and frequency vectors is not allocated
373 here the user must allocate space for these parameters once the number of
374 frequencies is known */
375
alloc_list()376 struct blkt *alloc_list()
377 {
378 struct blkt *blkt_ptr;
379
380 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
381 == (struct blkt *)NULL) {
382 error_exit(OUT_OF_MEMORY,"alloc_list; malloc() failed for (List) blkt structure");
383 }
384
385 blkt_ptr->type = LIST;
386 blkt_ptr->next_blkt = (struct blkt *)NULL;
387 blkt_ptr->blkt_info.list.freq = (double *)NULL;
388 blkt_ptr->blkt_info.list.amp = (double *)NULL;
389 blkt_ptr->blkt_info.list.phase = (double *)NULL;
390 blkt_ptr->blkt_info.list.nresp = 0;
391
392 return(blkt_ptr);
393 }
394
395 /* alloc_generic allocates space for a generic type filter structure and returns a pointer to that
396 structure.
397 Note: the space for the corner_freq, and corner_slope vectors is not allocated
398 here the user must allocate space for these parameters once the number of
399 frequencies is known */
400
alloc_generic()401 struct blkt *alloc_generic()
402 {
403 struct blkt *blkt_ptr;
404
405 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
406 == (struct blkt *)NULL) {
407 error_exit(OUT_OF_MEMORY,"alloc_generic; malloc() failed for (Generic) blkt structure");
408 }
409
410 blkt_ptr->type = GENERIC;
411 blkt_ptr->next_blkt = (struct blkt *)NULL;
412 blkt_ptr->blkt_info.generic.corner_slope = (double *)NULL;
413 blkt_ptr->blkt_info.generic.corner_freq = (double *)NULL;
414 blkt_ptr->blkt_info.generic.ncorners = 0;
415
416 return(blkt_ptr);
417 }
418
419 /* alloc_deci: allocates space for a decimation type filter structure and returns a pointer to that
420 structure. */
421
alloc_deci()422 struct blkt *alloc_deci()
423 {
424 struct blkt *blkt_ptr;
425
426 if((blkt_ptr = (struct blkt *) malloc(sizeof(struct blkt)))
427 == (struct blkt *)NULL) {
428 error_exit(OUT_OF_MEMORY,"alloc_deci; malloc() failed for (Decimation) blkt structure");
429 }
430
431 blkt_ptr->type = DECIMATION;
432 blkt_ptr->next_blkt = (struct blkt *)NULL;
433 blkt_ptr->blkt_info.decimation.sample_int = 0;
434 blkt_ptr->blkt_info.decimation.deci_fact = 0;
435 blkt_ptr->blkt_info.decimation.deci_offset = 0;
436 blkt_ptr->blkt_info.decimation.estim_delay = 0;
437 blkt_ptr->blkt_info.decimation.applied_corr = 0;
438
439 return(blkt_ptr);
440 }
441
442 /* alloc_stage: allocates space for a decimation type filter structure and returns a pointer to that
443 structure. */
444
alloc_stage()445 struct stage *alloc_stage()
446 {
447 struct stage *stage_ptr;
448
449 if((stage_ptr = (struct stage *) malloc(sizeof(struct stage)))
450 == (struct stage *)NULL) {
451 error_exit(OUT_OF_MEMORY,"alloc_stage; malloc() failed for stage structure");
452 }
453
454 stage_ptr->sequence_no = 0;
455 stage_ptr->output_units = 0;
456 stage_ptr->input_units = 0;
457 stage_ptr->first_blkt = (struct blkt *)NULL;
458 stage_ptr->next_stage = (struct stage *)NULL;
459
460 return(stage_ptr);
461 }
462
463 /* free_string_array: a routine that frees up the space associated with a
464 string list type structure */
465
free_string_array(struct string_array * lst)466 void free_string_array(struct string_array *lst) {
467 int i;
468
469 for(i = 0; i < lst->nstrings; i++) {
470 free(lst->strings[i]);
471 }
472 free(lst->strings);
473 free(lst);
474 }
475
476 /* free_scn: a routine that frees up the space associated with a
477 station-channel type structure */
478
free_scn(struct scn * ptr)479 void free_scn(struct scn *ptr) {
480
481
482 free(ptr->station);
483 free(ptr->network);
484 free(ptr->locid);
485 free(ptr->channel);
486
487 }
488
489 /* free_scn_list: a routine that frees up the space associated with a
490 station-channel list type structure */
491
free_scn_list(struct scn_list * lst)492 void free_scn_list(struct scn_list *lst) {
493 int i;
494
495 for(i = 0; i < lst->nscn; i++) {
496 free_scn(lst->scn_vec[i]);
497 free(lst->scn_vec[i]);
498 }
499 free(lst->scn_vec);
500 free(lst);
501 }
502
503 /* free_matched_files: a routine that frees up the space associated with a
504 matched files type structure */
505
free_matched_files(struct matched_files * lst)506 void free_matched_files(struct matched_files *lst) {
507 if(lst != (struct matched_files *)NULL) {
508 free_matched_files(lst->ptr_next);
509 if(lst->nfiles) {
510 free_file_list(lst->first_list);
511 free(lst->first_list);
512 }
513 free(lst);
514 lst = (struct matched_files *)NULL;
515 }
516 }
517
518 /* free_file_list: a routine that frees up the space associated with a
519 file list type structure */
520
free_file_list(struct file_list * lst)521 void free_file_list(struct file_list *lst) {
522
523 if(lst != (struct file_list *)NULL) {
524 free_file_list(lst->next_file);
525 if(lst->name != (char *)NULL)
526 free(lst->name);
527 if(lst->next_file != (struct file_list *)NULL)
528 free(lst->next_file);
529 }
530
531 }
532
533 /* free_pz: a routine that frees up the space associated with a pole-zero
534 type filter */
535
free_pz(struct blkt * blkt_ptr)536 void free_pz(struct blkt *blkt_ptr) {
537 if(blkt_ptr != (struct blkt *)NULL) {
538 if(blkt_ptr->blkt_info.pole_zero.zeros != (struct complex *)NULL)
539 free(blkt_ptr->blkt_info.pole_zero.zeros);
540 if(blkt_ptr->blkt_info.pole_zero.poles != (struct complex *)NULL)
541 free(blkt_ptr->blkt_info.pole_zero.poles);
542 free(blkt_ptr);
543 }
544 }
545
546 /* free_coeff: a routine that frees up the space associated with a coefficients
547 type filter */
548
free_coeff(struct blkt * blkt_ptr)549 void free_coeff(struct blkt *blkt_ptr) {
550 if(blkt_ptr != (struct blkt *)NULL) {
551 if(blkt_ptr->blkt_info.coeff.numer != (double *)NULL)
552 free(blkt_ptr->blkt_info.coeff.numer);
553 if(blkt_ptr->blkt_info.coeff.denom != (double *)NULL)
554 free(blkt_ptr->blkt_info.coeff.denom);
555 free(blkt_ptr);
556 }
557 }
558
559 /* free_fir: a routine that frees up the space associated with a fir
560 type filter */
561
free_fir(struct blkt * blkt_ptr)562 void free_fir(struct blkt *blkt_ptr) {
563 if(blkt_ptr != (struct blkt *)NULL) {
564 if(blkt_ptr->blkt_info.fir.coeffs != (double *)NULL)
565 free(blkt_ptr->blkt_info.fir.coeffs);
566 free(blkt_ptr);
567 }
568 }
569
570 /* free_list: a routine that frees up the space associated with a list
571 type filter */
572
free_list(struct blkt * blkt_ptr)573 void free_list(struct blkt *blkt_ptr) {
574 if(blkt_ptr != (struct blkt *)NULL) {
575 if(blkt_ptr->blkt_info.list.freq != (double *)NULL)
576 free(blkt_ptr->blkt_info.list.freq);
577 if(blkt_ptr->blkt_info.list.amp != (double *)NULL)
578 free(blkt_ptr->blkt_info.list.amp);
579 if(blkt_ptr->blkt_info.list.phase != (double *)NULL)
580 free(blkt_ptr->blkt_info.list.phase);
581 free(blkt_ptr);
582 }
583 }
584
585 /* free_generic: a routine that frees up the space associated with a generic
586 type filter */
587
free_generic(struct blkt * blkt_ptr)588 void free_generic(struct blkt *blkt_ptr) {
589 if(blkt_ptr != (struct blkt *)NULL) {
590 if(blkt_ptr->blkt_info.generic.corner_slope != (double *)NULL)
591 free(blkt_ptr->blkt_info.generic.corner_slope);
592 if(blkt_ptr->blkt_info.generic.corner_freq != (double *)NULL)
593 free(blkt_ptr->blkt_info.generic.corner_freq);
594 free(blkt_ptr);
595 }
596 }
597
598 /* free_gain: a routine that frees up the space associated with a gain
599 type filter */
600
free_gain(struct blkt * blkt_ptr)601 void free_gain(struct blkt *blkt_ptr) {
602 if(blkt_ptr != (struct blkt *)NULL) {
603 free(blkt_ptr);
604 }
605 }
606
607 /* free_deci: a routine that frees up the space associated with a decimation
608 type filter */
609
free_deci(struct blkt * blkt_ptr)610 void free_deci(struct blkt *blkt_ptr) {
611 if(blkt_ptr != (struct blkt *)NULL) {
612 free(blkt_ptr);
613 }
614 }
615
616 /* free_ref: a routine that frees up the space associated with a response
617 reference type filter */
618
free_ref(struct blkt * blkt_ptr)619 void free_ref(struct blkt *blkt_ptr) {
620
621
622 if(blkt_ptr != (struct blkt *)NULL) {
623 free(blkt_ptr);
624 }
625 }
626
627 /* free_stages: a routine that frees up the space associated with a stages in
628 a channel's response */
629
free_stages(struct stage * stage_ptr)630 void free_stages(struct stage *stage_ptr) {
631 struct blkt *this_blkt, *next_blkt;
632
633 if(stage_ptr != (struct stage *)NULL) {
634 free_stages(stage_ptr->next_stage);
635 this_blkt = stage_ptr->first_blkt;
636 while(this_blkt != (struct blkt *)NULL) {
637 next_blkt = this_blkt->next_blkt;
638 switch (this_blkt->type) {
639 case LAPLACE_PZ:
640 case ANALOG_PZ:
641 case IIR_PZ:
642 free_pz(this_blkt);
643 break;
644 case FIR_SYM_1:
645 case FIR_SYM_2:
646 case FIR_ASYM:
647 free_fir(this_blkt);
648 break;
649 case FIR_COEFFS:
650 free_coeff(this_blkt);
651 break;
652 case LIST:
653 free_list(this_blkt);
654 break;
655 case GENERIC:
656 free_generic(this_blkt);
657 break;
658 case DECIMATION:
659 free_deci(this_blkt);
660 break;
661 case GAIN:
662 free_gain(this_blkt);
663 break;
664 case REFERENCE:
665 free_ref(this_blkt);
666 break;
667 default:
668 break;
669 }
670 this_blkt = next_blkt;
671 }
672 free(stage_ptr);
673 }
674 }
675
676 /* free_channel: a routine that frees up the space associated with a channel's
677 filter sequence */
678
free_channel(struct channel * chan_ptr)679 void free_channel(struct channel *chan_ptr) {
680
681 free_stages(chan_ptr->first_stage);
682 strncpy(chan_ptr->staname,"",STALEN);
683 strncpy(chan_ptr->network,"",NETLEN);
684 strncpy(chan_ptr->locid,"",LOCIDLEN);
685 strncpy(chan_ptr->chaname,"",CHALEN);
686 strncpy(chan_ptr->beg_t,"",DATIMLEN);
687 strncpy(chan_ptr->end_t,"",DATIMLEN);
688 strncpy(chan_ptr->first_units,"",MAXLINELEN);
689 strncpy(chan_ptr->last_units,"",MAXLINELEN);
690 }
691
692 /* free_response: a routine that frees up the space associated with a linked
693 list of response information */
694
free_response(struct response * resp_ptr)695 void free_response(struct response *resp_ptr) {
696 struct response *this_resp, *next_resp;
697
698 this_resp = resp_ptr;
699 while(this_resp != (struct response *)NULL) {
700 next_resp = this_resp->next;
701 free(this_resp->rvec);
702 free(this_resp->freqs); /*IGD for v 3.2.17 */
703 free(this_resp);
704 this_resp = next_resp;
705 }
706 }
707