Skip to content

Commit af8e7d0

Browse files
committed
Fix argument type allocation
1 parent e7f4f48 commit af8e7d0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/types/zval.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ impl Zval {
5656
return self
5757
.reference()
5858
.or_else(|| self.indirect())
59-
.or(Some(self))
60-
.unwrap();
59+
.unwrap_or(self)
6160
}
6261

6362
/// Dereference the zval mutable, if it is a reference.
6463
pub fn dereference_mut(&mut self) -> &mut Self {
6564
if self.is_reference() {
65+
#[allow(clippy::unwrap_used)]
6666
return self.reference_mut().unwrap();
6767
}
6868
if self.is_indirect() {
69+
#[allow(clippy::unwrap_used)]
6970
return self.indirect_mut().unwrap();
7071
}
71-
return self;
72+
self
7273
}
7374

7475
/// Returns the value of the zval if it is a long.

src/zend/_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
ffi::{c_void, CString},
2+
ffi::c_void,
33
ptr,
44
};
55

@@ -8,7 +8,7 @@ use crate::{
88
zend_type, IS_MIXED, MAY_BE_ANY, MAY_BE_BOOL, _IS_BOOL, _ZEND_IS_VARIADIC_BIT,
99
_ZEND_SEND_MODE_SHIFT, _ZEND_TYPE_NAME_BIT, _ZEND_TYPE_NULLABLE_BIT,
1010
},
11-
flags::DataType,
11+
flags::DataType, types::ZendStr,
1212
};
1313

1414
/// Internal Zend type.
@@ -82,7 +82,7 @@ impl ZendType {
8282
allow_null: bool,
8383
) -> Option<Self> {
8484
Some(Self {
85-
ptr: CString::new(class_name).ok()?.into_raw() as *mut c_void,
85+
ptr: ZendStr::new(class_name, true).as_ptr() as *mut c_void,
8686
type_mask: _ZEND_TYPE_NAME_BIT
8787
| (if allow_null {
8888
_ZEND_TYPE_NULLABLE_BIT

0 commit comments

Comments
 (0)