diff options
Diffstat (limited to 'src/zsetu.c')
| -rw-r--r-- | src/zsetu.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/zsetu.c b/src/zsetu.c index 78b78bb..385403c 100644 --- 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; |
