commit 3cbe3666b87d1c256eddf2d26f2238bfc000083f
parent 787dbbf337bb238bea30d66d4bf43907bca20e19
Author: Mattias Andrée <maandree@kth.se>
Date: Tue, 1 Mar 2016 19:33:46 +0100
zsetu: change macro from CHARS_PER_TYPE to SIZE_MULTIPLE
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/zsetu.c b/src/zsetu.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
#include "internals"
-#define CHARS_PER_TYPE(t) (sizeof(t) / (BITS_PER_CHAR >> 3))
+#define SIZE_MULTIPLE(fit, in) ((sizeof(fit) + sizeof(in) - 1) / sizeof(in))
void
@@ -11,9 +11,9 @@ zsetu(z_t a, unsigned long long int b)
SET_SIGNUM(a, 0);
return;
}
- if (a->alloced < CHARS_PER_TYPE(b)) {
- a->alloced = CHARS_PER_TYPE(b);
- a->chars = realloc(a->chars, CHARS_PER_TYPE(b) * sizeof(*(a->chars)))
+ if (a->alloced < SIZE_MULTIPLE(b, *(a->chars))) {
+ a->alloced = SIZE_MULTIPLE(b, *(a->chars));
+ a->chars = realloc(a->chars, SIZE_MULTIPLE(b, *(a->chars)) * sizeof(*(a->chars)))
}
SET_SIGNUM(a, 1);
a->used = 0;