fix: pass **x instead
This is because when I pass *x then it's just a copy.
This commit is contained in:
+7
-7
@@ -133,9 +133,9 @@ static void refine_interval(double xl, double xr, double yl, double yr, double r
|
||||
return ;
|
||||
}
|
||||
|
||||
int init(double bmax, double rela_err_limit, int *size, double *x, double *y){
|
||||
if (x) free(x);
|
||||
if (y) free(y);
|
||||
int init(double bmax, double rela_err_limit, int *size, double **x, double **y){
|
||||
if (*x) free(*x);
|
||||
if (*y) free(*y);
|
||||
SampleData sample;
|
||||
sample.capacity = 1;
|
||||
sample.size=1;
|
||||
@@ -155,12 +155,12 @@ int init(double bmax, double rela_err_limit, int *size, double *x, double *y){
|
||||
//printf("Total sample points capacity: %d\n", sample.capacity);
|
||||
//printf("Total sample points number: %d\n", sample.size);
|
||||
*size = sample.size;
|
||||
x = malloc(sizeof(double) * sample.size);
|
||||
y = malloc(sizeof(double) * sample.size);
|
||||
*x = malloc(sizeof(double) * sample.size);
|
||||
*y = malloc(sizeof(double) * sample.size);
|
||||
for (int i = 0; i < sample.size; i++) {
|
||||
//printf("%.16g %.16g\n", sample.x[i], sample.y[i]);
|
||||
x[i] = sample.x[i];
|
||||
y[i] = sample.y[i];
|
||||
(*x)[i] = sample.x[i];
|
||||
(*y)[i] = sample.y[i];
|
||||
}
|
||||
|
||||
free(sample.x);
|
||||
|
||||
Reference in New Issue
Block a user