X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fmod.rs;h=98e964ff6efb5b7d20ec7fe419103ee25f98c6f0;hb=ce0ec2494f33662d8cfb14efc00cb49d22190e2c;hp=3d6f08accc3926d3153ecd45aab38498ce0c5f0e;hpb=c358de7979526421ebb18df376ee323a5dd6d96b;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 3d6f08a..98e964f 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -14,7 +14,7 @@ use bitcoin::secp256k1::recovery::RecoverableSignature as SecpRecoverableSignatu use bitcoin::bech32; use std::convert::TryInto; // Bindings need at least rustc 1.34 - +use core::ffi::c_void; use std::io::{Cursor, Read}; // TODO: We should use core2 here when we support no_std #[repr(C)] @@ -618,6 +618,18 @@ pub(crate) mod ObjOps { } } +#[cfg(test_mod_pointers)] +#[no_mangle] +/// This function exists for memory safety testing purposes. It should never be used in production +/// code +pub extern "C" fn __unmangle_inner_ptr(ptr: *const c_void) -> *const c_void { + if ptr as usize == 1 { + core::ptr::null() + } else { + unsafe { ptr.cast::().sub(4096).cast::() } + } +} + pub(crate) struct SmartPtr { ptr: *mut T, }