/********************************************************************** Close the file and free associated memory, but don't recurse included_from files, and don't free the actual memory where the inf record is stored (ie, the memory where the users pointer points to). This is used when closing an included file. ***********************************************************************/ static void inf_close_partial(struct inputfile *inf) { assert_sanity(inf); freelog(LOG_DEBUG, "inputfile: sub-closing \"%s\"", inf_filename(inf)); if (fz_ferror(inf->fp) != 0) { freelog(LOG_ERROR, "Error before closing %s: %s", inf_filename(inf), fz_strerror(inf->fp)); fz_fclose(inf->fp); inf->fp = NULL; } else if (fz_fclose(inf->fp) != 0) { freelog(LOG_ERROR, "Error closing %s", inf_filename(inf)); } if (inf->filename) { free(inf->filename); } inf->filename = NULL; astr_free(&inf->cur_line); astr_free(&inf->copy_line); astr_free(&inf->token); astr_free(&inf->partial); /* assign zeros for safety if accidently re-use etc: */ init_zeros(inf); inf->magic = ~INF_MAGIC; freelog(LOG_DEBUG, "inputfile: sub-closed ok"); }
explicit GridSpec( const ndarray<real_t, 2> position, const real_t scale) : n_dim_ (n_dim), scale (scale), box (init_box(position)), shape (init_shape()), zeros (init_zeros()), strides (init_strides()) { }
/********************************************************************** Open the stream, and return an allocated, initialized structure. Returns NULL if the file could not be opened. ***********************************************************************/ struct inputfile *inf_from_stream(fz_FILE * stream, datafilename_fn_t datafn) { struct inputfile *inf; assert(stream != NULL); inf = fc_malloc(sizeof(*inf)); init_zeros(inf); inf->filename = NULL; inf->fp = stream; inf->datafn = datafn; freelog(LOG_DEBUG, "inputfile: opened \"%s\" ok", inf_filename(inf)); return inf; }