-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement pre allocation context creation #125
Conversation
src/context.rs
Outdated
const DESCRIPTION: &'static str = "signing only"; | ||
|
||
fn deallocate(ptr: *mut [u8]) { | ||
let _ = ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be clearer to write
fn deallocate(_: *mut [u8]) {
// do nothing
}
I read let _ = ptr
as "drop ptr
" which is technically what's happening but it's a bit weird because dropping a pointer is a noop.
src/lib.rs
Outdated
@@ -570,7 +570,7 @@ impl<C: Context> Secp256k1<C> { | |||
} | |||
|
|||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context | |||
pub fn preallocate_size() -> usize { | |||
pub(crate) fn preallocate_size_gen() -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still export this. It's needed to estimate the allocation size in generic contexts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly didn't want to confuse the user with too many functions, some generic and some not
Confirmed that I can build and run a rust-wasm project with this. ACK. |
@apoelstra That's great :) Thanks! |
Hi,
After talking with @apoelstra and after the great feedback and discussion on #116
I wrote this new API.
If it's too broad of a change I can try to split it into smaller PRs.
After this there shouldn't be any free/malloc/fprintf symbols in this library.
(which will help both wasm(#124) and full
no-std
embedded devices)Edit: I missed a
realloc
(didn't even think of that one haha), rebased and pushed.Fixes #114
Fixes #117
Fixes #124