Fix of buffer overrun in interpolation at endpoint of interval.
Made cfunc.mod for tables more modular. Prevented buffer overrun when building file name. Added error checking for allocation failures in many locations. Made binary search for interpolation more efficient.
This commit is contained in:
parent
1d86e5a9c7
commit
ef6c8abb6c
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef gettokens_h_included
|
||||
#define gettokens_h_included
|
||||
|
||||
/* Type definition for each possible token returned. */
|
||||
typedef enum token_type_s { CNV_NO_TOK, CNV_STRING_TOK } Cnv_Token_Type_t;
|
||||
|
||||
char * CNVget_token(char **s, Cnv_Token_Type_t *type);
|
||||
char *CNVgettok(char **s);
|
||||
int cnv_get_spice_value(char *str, double *p_value);
|
||||
#endif /* gettokens_h_included */
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#include "eno2.h"
|
||||
#include "eno3.h"
|
||||
|
||||
typedef struct {
|
||||
int ix; /* size of array in x */
|
||||
int iy; /* size of array in y */
|
||||
int iz; /* size of array in z */
|
||||
|
||||
sf_eno3 newtable; /* the table, code borrowed from madagascar project */
|
||||
|
||||
/* Input values corresponding to each index. They define the value
|
||||
* in the domain at each index value */
|
||||
double *xcol; /* array of doubles in x */
|
||||
double *ycol; /* array of doubles in y */
|
||||
double *zcol; /* array of doubles in z */
|
||||
|
||||
double ***table; /* f(xi, yj, zk) */
|
||||
} Table3_Data_t;
|
||||
|
||||
void free_local_data(Table3_Data_t *loc);
|
||||
|
||||
|
||||
Table3_Data_t *init_local_data(const char *filename, int order);
|
||||
|
||||
/* Finds difference between column values */
|
||||
static inline double get_local_diff(int n, double *col, int ind)
|
||||
{
|
||||
if (ind >= n - 1) {
|
||||
return col[n - 1] - col[n - 2];
|
||||
}
|
||||
if (ind <= 0) {
|
||||
return col[1] - col[0];
|
||||
}
|
||||
return 0.5 * (col[ind + 1] - col[ind - 1]);
|
||||
} /* end of function get_local_diff */
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue