Skip to content

Commit a1aad39

Browse files
committed
add Reply::as_raw
See #265
1 parent 5f23596 commit a1aad39

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

build/cg/request.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ impl CodeGen {
354354
writeln!(out, " std::mem::forget(self);")?;
355355
writeln!(out, " raw")?;
356356
writeln!(out, " }}")?;
357+
writeln!(out)?;
358+
writeln!(out, " unsafe fn as_raw(&self) -> *const u8 {{")?;
359+
writeln!(out, " self.raw")?;
360+
writeln!(out, " }}")?;
357361
writeln!(out, "}}")?;
358362

359363
self.emit_debug_impl(out, reply_rs_typ, &reply.fields)?;

src/base.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ pub trait Reply {
311311
/// The returned pointer must be freed with [`libc::free`] to avoid any memory leak, or be used
312312
/// to build another reply.
313313
unsafe fn into_raw(self) -> *const u8;
314+
315+
/// Get the raw pointer of the XCB reply.
316+
///
317+
/// # Safety
318+
/// The returned pointer must NOT be freed. Passing this pointer to [`libc::free`] will result in a double free
319+
/// when the reply is dropped.
320+
unsafe fn as_raw(&self) -> *const u8;
314321
}
315322

316323
/// General trait for cookies returned by requests.

0 commit comments

Comments
 (0)