@@ -7,7 +7,7 @@ use Secp256k1;
7
7
#[ cfg( feature = "std" ) ]
8
8
pub use self :: std_only:: * ;
9
9
10
- /// A trait for all kinds of Context's that let's you define the exact flags and a function to deallocate memory.
10
+ /// A trait for all kinds of Context's that Lets you define the exact flags and a function to deallocate memory.
11
11
/// * DO NOT * implement it for your own types.
12
12
pub unsafe trait Context {
13
13
/// Flags for the ffi.
@@ -86,7 +86,8 @@ mod std_only {
86
86
}
87
87
88
88
impl < C : Context > Secp256k1 < C > {
89
- fn gen_new ( ) -> Secp256k1 < C > {
89
+ /// Lets you create a context in a generic manner(sign/verify/all)
90
+ pub fn gen_new ( ) -> Secp256k1 < C > {
90
91
let buf = vec ! [ 0u8 ; Self :: preallocate_size_gen( ) ] . into_boxed_slice ( ) ;
91
92
let ptr = Box :: into_raw ( buf) ;
92
93
Secp256k1 {
@@ -148,31 +149,32 @@ unsafe impl<'buf> Context for SignOnlyPreallocated<'buf> {
148
149
const FLAGS : c_uint = ffi:: SECP256K1_START_SIGN ;
149
150
const DESCRIPTION : & ' static str = "signing only" ;
150
151
151
- fn deallocate ( ptr : * mut [ u8 ] ) {
152
- let _ = ptr ;
152
+ fn deallocate ( _ptr : * mut [ u8 ] ) {
153
+ // Allocated by the user
153
154
}
154
155
}
155
156
156
157
unsafe impl < ' buf > Context for VerifyOnlyPreallocated < ' buf > {
157
158
const FLAGS : c_uint = ffi:: SECP256K1_START_VERIFY ;
158
159
const DESCRIPTION : & ' static str = "verification only" ;
159
160
160
- fn deallocate ( ptr : * mut [ u8 ] ) {
161
- let _ = ptr ;
161
+ fn deallocate ( _ptr : * mut [ u8 ] ) {
162
+ // Allocated by the user
162
163
}
163
164
}
164
165
165
166
unsafe impl < ' buf > Context for AllPreallocated < ' buf > {
166
167
const FLAGS : c_uint = SignOnlyPreallocated :: FLAGS | VerifyOnlyPreallocated :: FLAGS ;
167
168
const DESCRIPTION : & ' static str = "all capabilities" ;
168
169
169
- fn deallocate ( ptr : * mut [ u8 ] ) {
170
- let _ = ptr ;
170
+ fn deallocate ( _ptr : * mut [ u8 ] ) {
171
+ // Allocated by the user
171
172
}
172
173
}
173
174
174
175
impl < ' buf , C : Context + ' buf > Secp256k1 < C > {
175
- fn preallocated_gen_new ( buf : & ' buf mut [ u8 ] ) -> Result < Secp256k1 < C > , Error > {
176
+ /// Lets you create a context with preallocated buffer in a generic manner(sign/verify/all)
177
+ pub fn preallocated_gen_new ( buf : & ' buf mut [ u8 ] ) -> Result < Secp256k1 < C > , Error > {
176
178
if buf. len ( ) < Self :: preallocate_size_gen ( ) {
177
179
return Err ( Error :: NotEnoughMemory ) ;
178
180
}
0 commit comments