fix: pass **x instead

This is because when I pass *x then it's just a copy.
This commit is contained in:
2025-11-11 02:01:26 -05:00
parent 544dac3184
commit 0221a0aa25
2 changed files with 8 additions and 8 deletions
+7 -7
View File
@@ -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);