static int set_data_grid (Isis_Rmf_t *rmf, double *lo, double *hi, unsigned int n) /*{{{*/ { Client_Data_t *cl = (Client_Data_t *)rmf->client_data; Isis_Rmf_Grid_Type *g; unsigned int i; int order; Isis_free_rmf_grid (cl->ebounds); cl->ebounds = Isis_new_rmf_grid (n, NULL, NULL); if (cl->ebounds == NULL) return -1; g = cl->ebounds; if (abs(rmf->order) > 1) order = rmf->order; else order = 1; for (i = 0; i < n; i++) { g->bin_lo[i] = lo[i] / order; g->bin_hi[i] = hi[i] / order; } return 0; }
Isis_Rmf_Grid_Type *Isis_new_rmf_grid (unsigned int nbins, double *lo, double *hi) /*{{{*/ { Isis_Rmf_Grid_Type *g; if (NULL == (g = (Isis_Rmf_Grid_Type *) ISIS_MALLOC (sizeof(Isis_Rmf_Grid_Type)))) return NULL; memset ((char *)g, 0, sizeof (*g)); g->nbins = nbins; g->units = -1; if (NULL == (g->bin_lo = (double *) ISIS_MALLOC (nbins * sizeof(double))) || NULL == (g->bin_hi = (double *) ISIS_MALLOC (nbins * sizeof(double)))) { Isis_free_rmf_grid (g); g = NULL; return g; } if (lo == NULL) memset ((char *)g->bin_lo, 0, nbins*sizeof(double)); else memcpy ((char *)g->bin_lo, (char *)lo, nbins * sizeof(double)); if (hi == NULL) memset ((char *)g->bin_hi, 0, nbins*sizeof(double)); else memcpy ((char *)g->bin_hi, (char *)hi, nbins * sizeof(double)); return g; }
static int set_grid (Isis_Rmf_Grid_Type **g, double *lo, double *hi, unsigned int n) /*{{{*/ { Isis_free_rmf_grid (*g); *g = Isis_new_rmf_grid (n, NULL, NULL); if ((*g) == NULL) return -1; memcpy ((char *)(*g)->bin_lo, (char *)lo, n * sizeof(double)); memcpy ((char *)(*g)->bin_hi, (char *)hi, n * sizeof(double)); return 0; }
static void free_client_data (Client_Data_t *cl) /*{{{*/ { Elem_Type *end, *e; if (cl == NULL) return; e = cl->elem; end = cl->elem + cl->num_arf; while (e < end) { if (e->num_chan > 1) { ISIS_FREE(e->resp.v); ISIS_FREE(e->chan.v); } e++; } ISIS_FREE(cl->elem); Isis_free_rmf_grid (cl->arf); Isis_free_rmf_grid (cl->ebounds); }