From 37b7fdce8f1f0fbd01cfda8dc56026804ea0bd78 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Sun, 7 Dec 2025 18:52:39 -0500 Subject: [PATCH] fix: memcpy --- src/quick_select.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick_select.c b/src/quick_select.c index 4c2318c..29fda45 100644 --- a/src/quick_select.c +++ b/src/quick_select.c @@ -46,7 +46,7 @@ double percentile(const double *arr, size_t n, double perc) { } double *arr_copy = malloc(sizeof(double)*n); - memcpy(arr_copy, arr, n); + memcpy(arr_copy, arr, n*sizeof(double)); // nearest-rank: ceil(0.9*n) - 1 size_t k = (size_t)(perc*n) - 1; double ans = select_k(arr_copy, n, k);