11use core:: marker:: PhantomData ;
2+ use core:: mem:: ManuallyDrop ;
23use ptr;
34use ffi:: { self , CPtr } ;
45use ffi:: types:: { c_uint, c_void} ;
@@ -227,12 +228,12 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> {
227228 /// * The user must handle the freeing of the context(using the correct functions) by himself.
228229 /// * Violating these may lead to Undefined Behavior.
229230 ///
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 {
232233 ctx : raw_ctx,
233234 phantom : PhantomData ,
234235 buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
235- }
236+ } )
236237 }
237238}
238239
@@ -259,12 +260,12 @@ impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> {
259260 /// * The user must handle the freeing of the context(using the correct functions) by himself.
260261 /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior.,
261262 ///
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 {
264265 ctx : raw_ctx,
265266 phantom : PhantomData ,
266267 buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
267- }
268+ } )
268269 }
269270}
270271
@@ -291,11 +292,11 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> {
291292 /// * The user must handle the freeing of the context(using the correct functions) by himself.
292293 /// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior.,
293294 ///
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 {
296297 ctx : raw_ctx,
297298 phantom : PhantomData ,
298299 buf : ptr:: null_mut :: < [ u8 ; 0 ] > ( ) as * mut [ u8 ] ,
299- }
300+ } )
300301 }
301302}
0 commit comments