@@ -324,7 +324,7 @@ mod fuzz_dummy {
324
324
extern crate std;
325
325
use types:: * ;
326
326
use ffi:: * ;
327
- use self :: std:: ptr;
327
+ use self :: std:: { ptr, mem } ;
328
328
use self :: std:: boxed:: Box ;
329
329
330
330
extern "C" {
@@ -335,20 +335,31 @@ mod fuzz_dummy {
335
335
336
336
// Contexts
337
337
/// Creates a dummy context, tracking flags to ensure proper calling semantics
338
- pub unsafe fn secp256k1_context_create ( flags : c_uint ) -> * mut Context {
338
+ pub unsafe fn secp256k1_context_preallocated_create ( _ptr : * mut c_void , flags : c_uint ) -> * mut Context {
339
339
let b = Box :: new ( Context ( flags as i32 ) ) ;
340
340
Box :: into_raw ( b)
341
341
}
342
342
343
+ /// Return dummy size of context struct.
344
+ pub unsafe fn secp256k1_context_preallocated_size ( _flags : c_uint ) -> usize {
345
+ mem:: size_of :: < Context > ( )
346
+ }
347
+
348
+ /// Return dummy size of context struct.
349
+ pub unsafe fn secp256k1_context_preallocated_clone_size ( cx : * mut Context ) -> usize {
350
+ mem:: size_of :: < Context > ( )
351
+ }
352
+
343
353
/// Copies a dummy context
344
- pub unsafe fn secp256k1_context_clone ( cx : * mut Context ) -> * mut Context {
345
- let b = Box :: new ( Context ( ( * cx) . 0 ) ) ;
346
- Box :: into_raw ( b)
354
+ pub unsafe fn secp256k1_context_preallocated_clone ( cx : * const Context , prealloc : * mut c_void ) -> * mut Context {
355
+ let ret = prealloc as * mut Context ;
356
+ * ret = ( * cx) . clone ( ) ;
357
+ ret
347
358
}
348
359
349
- /// Frees a dummy context
350
- pub unsafe fn secp256k1_context_destroy ( cx : * mut Context ) {
351
- Box :: from_raw ( cx) ;
360
+ /// "Destroys" a dummy context
361
+ pub unsafe fn secp256k1_context_preallocated_destroy ( cx : * mut Context ) {
362
+ ( * cx) . 0 = 0 ;
352
363
}
353
364
354
365
/// Asserts that cx is properly initialized
0 commit comments