From a666ae690ad548b5f357e70ed124aa3ab64afa5b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Jan 2019 10:43:02 -0800 Subject: mpi: use wchar_t string for text-to-bignum. * mpi/mpi.c (mp_read_radix): Take const wchar_t * string rather than unsigned char *. (s_mp_tovalue): Take character argument as wchar_t rather than int. * mpi/mpi.h (mp_read_radix): Declaration updated. * lib.c (int_str): Avoid a malloc/free and UTF-8 conversion by passing the original wide string to mp_read_radix. This removes a TODO dating back to December 2011. --- lib.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index a1a203b7..925bf638 100644 --- a/lib.c +++ b/lib.c @@ -4600,11 +4600,8 @@ val int_str(val str, val base) if ((value == LONG_MAX || value == LONG_MIN) && errno == ERANGE) { val bignum = make_bignum(); - size_t size; - unsigned char *ucs = utf8_dup_to_buf(wcs, &size, 1); - mp_err err = mp_read_radix(mp(bignum), ucs, b); + mp_err err = mp_read_radix(mp(bignum), wcs, b); - free(ucs); /* TODO: make wchar_t version of mp_read_radix. */ gc_hint(str); if (err != MP_OKAY) -- cgit v1.2.3