Skip to content

Commit 48b4df7

Browse files
committed
add Pool::as_ptr, review feedback
1 parent 0c6c85a commit 48b4df7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/async_/resolver.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,8 @@ impl<'a> Resolution<'a> {
259259
.copy_to_nonoverlapping(sockaddr.cast(), addr.socklen as usize)
260260
};
261261

262-
let name = unsafe {
263-
ngx_str_t::from_bytes(pool.as_ref() as *const _ as *mut _, addr.name.as_bytes())
264-
}
265-
.ok_or(Error::AllocationFailed)?;
262+
let name = unsafe { ngx_str_t::from_bytes(pool.as_ptr(), addr.name.as_bytes()) }
263+
.ok_or(Error::AllocationFailed)?;
266264

267265
Ok(ngx_addr_t {
268266
sockaddr,

src/core/pool.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ impl Pool {
145145
Pool(NonNull::new_unchecked(pool))
146146
}
147147

148+
/// Expose the underlying `ngx_pool_t` pointer, for use with `ngx::ffi`
149+
/// functions.
150+
pub fn as_ptr(&self) -> *mut ngx_pool_t {
151+
self.0.as_ptr()
152+
}
153+
148154
/// Creates a buffer of the specified size in the memory pool.
149155
///
150156
/// Returns `Some(TemporaryBuffer)` if the buffer is successfully created, or `None` if

0 commit comments

Comments
 (0)