diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-01 19:33:46 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-01 19:33:46 +0100 |
| commit | 3cbe3666b87d1c256eddf2d26f2238bfc000083f (patch) | |
| tree | 909ceb6145931991fbdcf3e6edae79a8c3bc2504 /src | |
| parent | Add zcmp, zcmpi, zcmpu, zcmpmag, zset, zseti, and zsetu (diff) | |
| download | libzahl-3cbe3666b87d1c256eddf2d26f2238bfc000083f.tar.gz libzahl-3cbe3666b87d1c256eddf2d26f2238bfc000083f.tar.bz2 libzahl-3cbe3666b87d1c256eddf2d26f2238bfc000083f.tar.xz | |
zsetu: change macro from CHARS_PER_TYPE to SIZE_MULTIPLE
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
| -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; |
