From cda9aa827451f06b530e15df16e499c32d6c6e33 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Apr 2020 18:55:19 -0700 Subject: [PATCH 1/2] u3: fixes rock:load size printf --- pkg/urbit/noun/manage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 64a6621f1..9c466836d 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1742,7 +1742,7 @@ u3m_rock_load(c3_c* dir_c, c3_d evt_d) // XX u3m_file bails, but we'd prefer to return errors // u3_noun fil = u3m_file(nam_c); - u3a_print_memory(stderr, "rock: load", u3r_met(3, fil)); + u3a_print_memory(stderr, "rock: load", u3r_met(5, fil)); u3_noun pro = u3m_soft(0, u3ke_cue, fil); From 8c9df5599229e2351628412ae8852fad776b32fb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 30 Apr 2020 14:53:14 -0700 Subject: [PATCH 2/2] u3: switches GMP import assert to conditional --- pkg/urbit/noun/retrieve.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/urbit/noun/retrieve.c b/pkg/urbit/noun/retrieve.c index 1316896b2..f7f32e19d 100644 --- a/pkg/urbit/noun/retrieve.c +++ b/pkg/urbit/noun/retrieve.c @@ -1092,10 +1092,14 @@ u3r_mp(mpz_t a_mp, u3a_atom* b_u = u3a_to_ptr(b); c3_w len_w = b_u->len_w; - // slight deficiency in the GMP API. + // avoid reallocation on import, if possible // - c3_assert(!(len_w >> 27)); - mpz_init2(a_mp, len_w << 5); + if ( (len_w >> 27) ) { + mpz_init(a_mp); + } + else { + mpz_init2(a_mp, len_w << 5); + } mpz_import(a_mp, len_w, -1, sizeof(c3_w), 0, 0, b_u->buf_w); }