[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 68/69: scm_to_ipv6 uses scm_to_mpz
From: |
Andy Wingo |
Subject: |
[Guile-commits] 68/69: scm_to_ipv6 uses scm_to_mpz |
Date: |
Fri, 7 Jan 2022 08:27:31 -0500 (EST) |
wingo pushed a commit to branch wip-inline-digits
in repository guile.
commit eec9f424e1b636ffeb65e2f3445b9816751d63e1
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Fri Jan 7 13:39:33 2022 +0100
scm_to_ipv6 uses scm_to_mpz
* libguile/socket.c (scm_to_ipv6): Use scm_to_mpz.
---
libguile/socket.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/libguile/socket.c b/libguile/socket.c
index e9c658ed7..77cdd74ef 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -255,10 +255,16 @@ scm_to_ipv6 (uint8_t dst[16], SCM src)
else if (SCM_BIGP (src))
{
size_t count;
+ mpz_t z;
- if ((mpz_sgn (SCM_I_BIG_MPZ (src)) < 0)
- || mpz_sizeinbase (SCM_I_BIG_MPZ (src), 2) > 128)
- scm_out_of_range (NULL, src);
+ mpz_init (z);
+ scm_to_mpz (src, z);
+
+ if (mpz_sgn (z) < 0 || mpz_sizeinbase (z, 2) > 128)
+ {
+ mpz_clear (z);
+ scm_out_of_range (NULL, src);
+ }
memset (dst, 0, 16);
mpz_export (dst,
@@ -267,8 +273,8 @@ scm_to_ipv6 (uint8_t dst[16], SCM src)
16, /* chunks are 16 bytes long */
1, /* big-endian byte ordering */
0, /* "nails" -- leading unused bits per chunk */
- SCM_I_BIG_MPZ (src));
- scm_remember_upto_here_1 (src);
+ z);
+ mpz_clear (z);
}
else
scm_wrong_type_arg_msg ("scm_to_ipv6", 0, src, "integer");
- [Guile-commits] 50/69: Reimplement scm_from_int8 etc, (continued)
- [Guile-commits] 50/69: Reimplement scm_from_int8 etc, Andy Wingo, 2022/01/07
- [Guile-commits] 56/69: Reimplement exact-integer-sqrt with integers.[ch], Andy Wingo, 2022/01/07
- [Guile-commits] 55/69: scm_to_mpz uses integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 62/69: Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c, Andy Wingo, 2022/01/07
- [Guile-commits] 61/69: Simplify scm_exact_integer_quotient, Andy Wingo, 2022/01/07
- [Guile-commits] 63/69: Simplify magnitude, angle, Andy Wingo, 2022/01/07
- [Guile-commits] 64/69: Use scm_integer_to_double_z in numbers.c instead of big2dbl, Andy Wingo, 2022/01/07
- [Guile-commits] 67/69: Finish srfi-60 port off old scm mpz API, Andy Wingo, 2022/01/07
- [Guile-commits] 66/69: Start porting srfi-60 off the bad bignum interfaces, Andy Wingo, 2022/01/07
- [Guile-commits] 69/69: Bignums avoid both custom GMP allocator and finalizers, Andy Wingo, 2022/01/07
- [Guile-commits] 68/69: scm_to_ipv6 uses scm_to_mpz,
Andy Wingo <=