diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-07 12:15:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-07 14:38:48 +0300 |
commit | d2296cd5ec433fcfeee958d1490925befdef1447 (patch) | |
tree | 070bf7f55613ffd9a092813f3a1868b193d5ee52 /extern/curve_fit_nd/intern | |
parent | 65dd1d7d081d437a918fbb9fc37515ba262d44d0 (diff) |
Fix error copying cubic data
Diffstat (limited to 'extern/curve_fit_nd/intern')
-rw-r--r-- | extern/curve_fit_nd/intern/curve_fit_cubic.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic.c b/extern/curve_fit_nd/intern/curve_fit_cubic.c index f4f5d112a93..fdcb9f8de7d 100644 --- a/extern/curve_fit_nd/intern/curve_fit_cubic.c +++ b/extern/curve_fit_nd/intern/curve_fit_cubic.c @@ -119,6 +119,11 @@ static Cubic *cubic_alloc(const uint dims) return malloc(cubic_alloc_size(dims)); } +static void cubic_copy(Cubic *cubic_dst, const Cubic *cubic_src, const uint dims) +{ + memcpy(cubic_dst, cubic_src, cubic_alloc_size(dims)); +} + static void cubic_init( Cubic *cubic, const double p0[], const double p1[], const double p2[], const double p3[], @@ -766,7 +771,7 @@ static bool fit_cubic_to_points( } else { Cubic *cubic_test = alloca(cubic_alloc_size(dims)); - *cubic_test = *r_cubic; + cubic_copy(cubic_test, r_cubic, dims); /* If error not too large, try some reparameterization and iteration */ double *u_prime = malloc(sizeof(double) * points_offset_len); @@ -788,13 +793,13 @@ static bool fit_cubic_to_points( free(u_prime); free(u); - *r_cubic = *cubic_test; + cubic_copy(r_cubic, cubic_test, dims); *r_error_max_sq = error_max_sq; *r_split_index = split_index; return true; } else if (error_max_sq < *r_error_max_sq) { - *r_cubic = *cubic_test; + cubic_copy(r_cubic, cubic_test, dims); *r_error_max_sq = error_max_sq; *r_split_index = split_index; } |