1
1
use core:: marker:: PhantomData ;
2
+ use core:: mem:: ManuallyDrop ;
2
3
use ptr;
3
4
use ffi:: { self , CPtr } ;
4
5
use ffi:: types:: { c_uint, c_void} ;
@@ -227,12 +228,12 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> {
227
228
/// * The user must handle the freeing of the context(using the correct functions) by himself.
228
229
/// * Violating these may lead to Undefined Behavior.
229
230
///
230
- pub unsafe fn from_raw_all ( raw_ctx : * mut ffi:: Context ) -> Secp256k1 < AllPreallocated < ' buf > > {
231
- Secp256k1 {
231
+ pub unsafe fn from_raw_all ( raw_ctx : * mut ffi:: Context ) -> ManuallyDrop < Secp256k1 < AllPreallocated < ' buf > > > {
232
+ ManuallyDrop :: new ( Secp256k1 {
232
233
ctx : raw_ctx,
233
234
phantom : PhantomData ,
234
235
buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
235
- }
236
+ } )
236
237
}
237
238
}
238
239
@@ -259,12 +260,12 @@ impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> {
259
260
/// * The user must handle the freeing of the context(using the correct functions) by himself.
260
261
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior.,
261
262
///
262
- pub unsafe fn from_raw_signining_only ( raw_ctx : * mut ffi:: Context ) -> Secp256k1 < SignOnlyPreallocated < ' buf > > {
263
- Secp256k1 {
263
+ pub unsafe fn from_raw_signining_only ( raw_ctx : * mut ffi:: Context ) -> ManuallyDrop < Secp256k1 < SignOnlyPreallocated < ' buf > > > {
264
+ ManuallyDrop :: new ( Secp256k1 {
264
265
ctx : raw_ctx,
265
266
phantom : PhantomData ,
266
267
buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
267
- }
268
+ } )
268
269
}
269
270
}
270
271
@@ -291,11 +292,11 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> {
291
292
/// * The user must handle the freeing of the context(using the correct functions) by himself.
292
293
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior.,
293
294
///
294
- pub unsafe fn from_raw_verification_only ( raw_ctx : * mut ffi:: Context ) -> Secp256k1 < VerifyOnlyPreallocated < ' buf > > {
295
- Secp256k1 {
295
+ pub unsafe fn from_raw_verification_only ( raw_ctx : * mut ffi:: Context ) -> ManuallyDrop < Secp256k1 < VerifyOnlyPreallocated < ' buf > > > {
296
+ ManuallyDrop :: new ( Secp256k1 {
296
297
ctx : raw_ctx,
297
298
phantom : PhantomData ,
298
299
buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
299
- }
300
+ } )
300
301
}
301
302
}
0 commit comments