diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-12-14 12:24:24 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-12-14 12:24:24 -0600 |
commit | 85f94874c912e0cc09a69404929b6d7b4f4fc1c6 (patch) | |
tree | 3ba673f263e990eca664a317fea72edeeeb559e3 /src/misc.c | |
parent | 99db8e8e14696bfbf812b655d4a9160500afea11 (diff) | |
download | sddm-85f94874c912e0cc09a69404929b6d7b4f4fc1c6.tar.gz sddm-85f94874c912e0cc09a69404929b6d7b4f4fc1c6.tar.bz2 sddm-85f94874c912e0cc09a69404929b6d7b4f4fc1c6.zip |
fix another bug in combinations_with_replacement()
Also, fix a few memory leaks in test.c.
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -726,14 +726,14 @@ void combinations_with_replacement(size_t n, size_t r, size_t *result, size_t *l size_t i, j; size_t *tmp; - tmp = malloc(sizeof(size_t)*n*ipow(n,r)); + tmp = malloc(sizeof(size_t)*r*ipow(n,r)); product(n,r,tmp); *len = 0; for (i = 0; i < ipow(n,r); i++) { if (is_sorted(tmp+i*r,r)) { - for (j = 0; j < n; j++) { + for (j = 0; j < r; j++) { result[(*len)*r+j] = tmp[i*r+j]; } *len += 1; |