Skip to content

Commit 25a66fc

Browse files
committed
refactor: remove CString conversion when updating Zend hash string keys
1 parent 3c3f8e0 commit 25a66fc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::CString;
1+
22
use std::mem;
33

44
use ext_php_rs::boxed::ZBox;
@@ -208,11 +208,9 @@ fn build_php_map(
208208
#[allow(clippy::cast_sign_loss)]
209209
zend_hash_index_update(&mut *ht, idx as u64, std::ptr::addr_of_mut!(child))
210210
} else {
211-
let c_key = CString::new(key.as_str())
212-
.map_err(|_| PhpException::default("Map key contains null byte".to_string()))?;
213211
zend_hash_str_update(
214212
&mut *ht,
215-
c_key.as_ptr(),
213+
key.as_ptr() as *const i8,
216214
key.len(),
217215
std::ptr::addr_of_mut!(child),
218216
)

0 commit comments

Comments
 (0)