aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/misc.c b/src/misc.c
index 56760e4..a610944 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -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;