@@ -18,7 +18,7 @@ use crate::{
1818/// Builder for registering a class in PHP.
1919pub struct ClassBuilder {
2020 name : String ,
21- ptr : Box < ClassEntry > ,
21+ ce : ClassEntry ,
2222 extends : Option < & ' static ClassEntry > ,
2323 interfaces : Vec < & ' static ClassEntry > ,
2424 methods : Vec < FunctionEntry > ,
@@ -35,13 +35,11 @@ impl ClassBuilder {
3535 ///
3636 /// * `name` - The name of the class.
3737 pub fn new < T : Into < String > > ( name : T ) -> Self {
38- // SAFETY: A zeroed class entry is in an initalized state, as it is a raw C type
39- // whose fields do not have a drop implementation.
40- let ptr = unsafe { Box :: new ( MaybeUninit :: zeroed ( ) . assume_init ( ) ) } ;
41-
4238 Self {
4339 name : name. into ( ) ,
44- ptr,
40+ // SAFETY: A zeroed class entry is in an initalized state, as it is a raw C type
41+ // whose fields do not have a drop implementation.
42+ ce : unsafe { MaybeUninit :: zeroed ( ) . assume_init ( ) } ,
4543 extends : None ,
4644 interfaces : vec ! [ ] ,
4745 methods : vec ! [ ] ,
@@ -143,7 +141,7 @@ impl ClassBuilder {
143141 ///
144142 /// * `flags` - Flags relating to the class. See [`ClassFlags`].
145143 pub fn flags ( mut self , flags : ClassFlags ) -> Self {
146- self . ptr . ce_flags = flags. bits ( ) ;
144+ self . ce . ce_flags = flags. bits ( ) ;
147145 self
148146 }
149147
@@ -225,15 +223,15 @@ impl ClassBuilder {
225223 ///
226224 /// Returns an [`Error`] variant if the class could not be registered.
227225 pub fn build ( mut self ) -> Result < & ' static mut ClassEntry > {
228- self . ptr . name = ZendStr :: new_interned ( & self . name , true ) ?. into_raw ( ) ;
226+ self . ce . name = ZendStr :: new_interned ( & self . name , true ) ?. into_raw ( ) ;
229227
230228 self . methods . push ( FunctionEntry :: end ( ) ) ;
231229 let func = Box :: into_raw ( self . methods . into_boxed_slice ( ) ) as * const FunctionEntry ;
232- self . ptr . info . internal . builtin_functions = func;
230+ self . ce . info . internal . builtin_functions = func;
233231
234232 let class = unsafe {
235233 zend_register_internal_class_ex (
236- self . ptr . as_mut ( ) ,
234+ & mut self . ce ,
237235 match self . extends {
238236 Some ( ptr) => ( ptr as * const _ ) as * mut _ ,
239237 None => std:: ptr:: null_mut ( ) ,
0 commit comments