mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-12-03 10:07:44 +01:00
Fix construction of native classes and any class with properties
This commit is contained in:
parent
ab2af4581d
commit
c8c1df06e2
@ -41,8 +41,18 @@ impl ZendObject {
|
|||||||
// SAFETY: Using emalloc to allocate memory inside Zend arena. Casting `ce` to
|
// SAFETY: Using emalloc to allocate memory inside Zend arena. Casting `ce` to
|
||||||
// `*mut` is valid as the function will not mutate `ce`.
|
// `*mut` is valid as the function will not mutate `ce`.
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let ptr = match ce.__bindgen_anon_2.create_object {
|
||||||
|
None => {
|
||||||
let ptr = zend_objects_new(ce as *const _ as *mut _);
|
let ptr = zend_objects_new(ce as *const _ as *mut _);
|
||||||
|
if ptr.is_null() {
|
||||||
|
panic!("Failed to allocate memory for Zend object")
|
||||||
|
}
|
||||||
object_properties_init(ptr, ce as *const _ as *mut _);
|
object_properties_init(ptr, ce as *const _ as *mut _);
|
||||||
|
ptr
|
||||||
|
},
|
||||||
|
Some(v) => v(ce as *const _ as *mut _)
|
||||||
|
};
|
||||||
|
|
||||||
ZBox::from_raw(
|
ZBox::from_raw(
|
||||||
ptr.as_mut()
|
ptr.as_mut()
|
||||||
.expect("Failed to allocate memory for Zend object"),
|
.expect("Failed to allocate memory for Zend object"),
|
||||||
|
Loading…
Reference in New Issue
Block a user