Merge pull request #2922 from urbit/rock-load-tweaks

vere: improves jammed state reloading in |pack
This commit is contained in:
Joe Bryan 2020-05-21 23:00:17 -07:00 committed by GitHub
commit 32f7bfca90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -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 // XX u3m_file bails, but we'd prefer to return errors
// //
u3_noun fil = u3m_file(nam_c); 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); u3_noun pro = u3m_soft(0, u3ke_cue, fil);

View File

@ -1092,10 +1092,14 @@ u3r_mp(mpz_t a_mp,
u3a_atom* b_u = u3a_to_ptr(b); u3a_atom* b_u = u3a_to_ptr(b);
c3_w len_w = b_u->len_w; 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)); if ( (len_w >> 27) ) {
mpz_init2(a_mp, len_w << 5); 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); mpz_import(a_mp, len_w, -1, sizeof(c3_w), 0, 0, b_u->buf_w);
} }