Skip to content

Commit b0e8484

Browse files
committed
ffi: remove c_set_rawBuffer method
This one was easy.
1 parent 5dab248 commit b0e8484

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

simplicity-sys/depend/env.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ const size_t rustsimplicity_0_5_c_alignof_rawElementsTransaction = alignof(rawEl
2525
const size_t rustsimplicity_0_5_c_alignof_rawElementsTapEnv = alignof(rawElementsTapEnv);
2626
const size_t rustsimplicity_0_5_c_alignof_txEnv = alignof(txEnv);
2727

28-
void rustsimplicity_0_5_c_set_rawElementsBuffer(rawElementsBuffer *result, const unsigned char *buf, unsigned int len)
29-
{
30-
*result = (rawElementsBuffer){.buf = buf, .len = len};
31-
}
32-
3328
void rustsimplicity_0_5_c_set_rawElementsTransaction(rawElementsTransaction *result, unsigned int version,
3429
const unsigned char *txid,
3530
const rawElementsInput *input, unsigned int numInputs,

simplicity-sys/src/c_jets/c_env/elements.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ extern "C" {
173173
#[link_name = "rustsimplicity_0_5_c_alignof_txEnv"]
174174
pub static c_alignof_txEnv: c_size_t;
175175

176-
#[link_name = "rustsimplicity_0_5_c_set_rawElementsBuffer"]
177-
pub fn c_set_rawBuffer(res: *mut CRawBuffer, buf: *const c_uchar, len: c_uint);
178-
179176
#[link_name = "rustsimplicity_0_5_c_set_rawElementsTransaction"]
180177
pub fn c_set_rawTransaction(
181178
result: *mut CRawTransaction,
@@ -226,10 +223,9 @@ impl Drop for CTxEnv {
226223

227224
impl CRawBuffer {
228225
pub fn new(buf: &[c_uchar]) -> Self {
229-
unsafe {
230-
let mut raw_buffer = std::mem::MaybeUninit::<Self>::uninit();
231-
c_set_rawBuffer(raw_buffer.as_mut_ptr(), buf.as_ptr(), buf.len() as c_uint);
232-
raw_buffer.assume_init()
226+
Self {
227+
ptr: buf.as_ptr(),
228+
len: buf.len().try_into().expect("sane buffer lengths"),
233229
}
234230
}
235231
}

0 commit comments

Comments
 (0)