update: pass pointers into init()

This commit is contained in:
2025-11-10 16:13:17 -05:00
parent b9954ff8fa
commit 3dc107ad71

View File

@@ -132,7 +132,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 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;
@@ -151,8 +153,13 @@ int init(double bmax, double rela_err_limit){
//output
//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);
for (int i = 0; i < sample.size; i++) {
printf("%.16g %.16g\n", sample.x[i], sample.y[i]);
//printf("%.16g %.16g\n", sample.x[i], sample.y[i]);
x[i] = sample.x[i];
y[i] = sample.y[i];
}
free(sample.x);