int sd_alloc(int n_msec, int n_trials) { static int old_msec = 0; static int old_trials = 0; static int first = 1; register int i, len; msec = n_msec; trials = n_trials; if (first || (msec > old_msec) || (trials > old_trials)) { old_msec = n_msec * 1; /* make extra */ old_trials = n_trials; if (first) first = 0; else sd_free(); } else { return(0); /* already big enough */ } /* * allocate big enough to do fir filtering */ len = old_msec + (FILT_OFF * 2); if((sd_avg = (DFILTER *) dyn_alloc(len, sizeof(*sd_avg), "sd_alloc(): sd_avg")) == (char *)NULL) { return(-1); } else { memset(sd_avg, 0, (len * sizeof(*sd_avg))); } if((sd_se = (DFILTER *) dyn_alloc(len, sizeof(*sd_se), "sd_alloc(): sd_se")) == (char *)NULL) { return(-1); } if((sh_left = (int *) dyn_alloc(old_trials, sizeof(*sh_left), "sd_alloc(): sh_left")) == (char *)NULL) { return(-1); } if((sh_corr = (float *) dyn_alloc(old_trials, sizeof(*sh_corr), "sd_alloc(): sh_corr")) == (char *)NULL) { return(-1); } if((sd_ind =(DFILTER **) dyn_palloc(old_trials, sizeof(*sd_ind), len, sizeof(**sd_ind), "sd_alloc(): sd_ind")) == (char *)NULL) { return(-1); } /* * offset pointers to beginning of data */ sd_avg = &sd_avg[FILT_OFF]; sd_se = &sd_se[FILT_OFF]; for (i = 0; sd_ind[i] != NULL; i++) { sd_ind[i] = &sd_ind[i][FILT_OFF]; } }
/* * Ensure that the given dyn-string is empty. */ void dyn_init(DYN ** p, size_t len) { DYN *q = dyn_alloc(*p, len); q->text[q->cur_length = 0] = EOS; *p = q; }
static void typeover(int c) { size_t need = (size_t) Tcol + 1; if (need >= END_COL) { need = (need * 5) / 4; my_text = dyn_alloc(my_text, need); my_over = dyn_alloc(my_over, need); } if ((Over[Tcol] = Text[Tcol]) != EOS) { if (ispunct(UCH(Text[Tcol]))) Text[Tcol] = (char) c; } else Text[Tcol] = (char) c; if (++Tcol > Tlen) { Tlen = Tcol; Text[Tlen] = EOS; } }
void *zmalloc0 (long size) { void *res = dyn_alloc (size, PTRSIZE); assert (res); memset (res, 0, size); return res; }
void *zmalloc (long size) { void *res = dyn_alloc (size, PTRSIZE); assert (res); return res; }