From e46d7fa28642caf0a913d4a3c65f0222908653f3 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 25 Mar 2021 16:53:05 +0000 Subject: [PATCH] fixed minor flaws in the code --- lib/bigint.c | 8 ++++++-- lib/std.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/bigint.c b/lib/bigint.c index f03f5b1..710e5f3 100644 --- a/lib/bigint.c +++ b/lib/bigint.c @@ -315,7 +315,7 @@ int hcl_inttoooi (hcl_t* hcl, hcl_oop_t x, hcl_ooi_t* i) int n; n = hcl_inttooow(hcl, x, &w); - if (n < 0) + if (n < 0) { HCL_ASSERT (hcl, HCL_TYPE_MAX(hcl_ooi_t) + HCL_TYPE_MIN(hcl_ooi_t) == -1); /* assume 2's complement */ if (w > (hcl_oow_t)HCL_TYPE_MAX(hcl_ooi_t) + 1) @@ -377,7 +377,7 @@ static HCL_INLINE int bigint_to_uintmax (hcl_t* hcl, hcl_oop_t num, hcl_uintmax_ case 4: *w = ((hcl_uintmax_t)HCL_OBJ_GET_HALFWORD_VAL(num, 0) << HCL_LIW_BITS * 3) | - ((hcl_uintmax_t)HCL_OBJ_GET_HALFWORD_VAL(num, 1) << HCL_LIW_BITS * 2) | + ((hcl_uintmax_t)HCL_OBJ_GET_HALFWORD_VAL(num, 1) << HCL_LIW_BITS * 2) | ((hcl_uintmax_t)HCL_OBJ_GET_HALFWORD_VAL(num, 2) << HCL_LIW_BITS * 1) | HCL_OBJ_GET_HALFWORD_VAL(num, 3); goto done; @@ -640,6 +640,9 @@ hcl_oop_t hcl_ooitoint (hcl_t* hcl, hcl_ooi_t i) } } +#if (HCL_SIZEOF_UINTMAX_T == HCL_SIZEOF_OOW_T) + /* do nothing. required macros are defined in hcl.h */ +#else hcl_oop_t hcl_intmaxtoint (hcl_t* hcl, hcl_intmax_t i) { if (HCL_IN_SMOOI_RANGE(i)) @@ -663,6 +666,7 @@ hcl_oop_t hcl_uintmaxtoint (hcl_t* hcl, hcl_uintmax_t i) return make_bigint_with_uintmax(hcl, i); } } +#endif static HCL_INLINE hcl_oop_t expand_bigint (hcl_t* hcl, hcl_oop_t oop, hcl_oow_t inc) { diff --git a/lib/std.c b/lib/std.c index b130545..415e5e5 100644 --- a/lib/std.c +++ b/lib/std.c @@ -1084,7 +1084,7 @@ static void free_heap (hcl_t* hcl, void* ptr) actual_ptr = (hcl_oow_t*)ptr - 1; munmap (actual_ptr, *actual_ptr); #else - return HCL_MMGR_FREE(hcl->_mmgr, ptr); + HCL_MMGR_FREE(hcl->_mmgr, ptr); #endif }