From: Raphaƫl Gertz Date: Tue, 26 Jun 2018 07:41:45 +0000 (+0200) Subject: Move handler as global like in X-Git-Url: https://git.rapsys.eu/bbcode/commitdiff_plain/c6546ba7c986db18ac9e22d17b1d7075b8f3416c Move handler as global like in https://wiki.php.net/phpng-upgrading --- diff --git a/bbcode.c b/bbcode.c index 3a9ac76..8c15a10 100644 --- a/bbcode.c +++ b/bbcode.c @@ -18,11 +18,12 @@ typedef struct _bbcode_object { zval *smiley; zval *flag;*/ zend_long flag; - zend_object_handlers bbcode_handlers; zend_object std; } bbcode_object; /* True global resources - no need for thread safety here */ +zend_object_handlers bbcode_handlers; + /* BBCode object */ zend_class_entry *bbcode_ce; @@ -114,13 +115,7 @@ static zend_object *bbcode_clone(zval *obj TSRMLS_DC) { zend_object_std_init(&newobj->std, Z_OBJCE_P(obj) TSRMLS_CC); object_properties_init(&newobj->std, Z_OBJCE_P(obj) TSRMLS_CC); - memcpy(&newobj->bbcode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - newobj->bbcode_handlers.offset = XtOffsetOf(bbcode_object, std); - newobj->bbcode_handlers.dtor_obj = (zend_object_dtor_obj_t) bbcode_destroy; - newobj->bbcode_handlers.free_obj = (zend_object_free_obj_t) bbcode_free; - newobj->bbcode_handlers.clone_obj = (zend_object_clone_obj_t) bbcode_clone; - - newobj->std.handlers = &(newobj->bbcode_handlers); + //newobj->std.handlers = &bbcode_handlers; zend_objects_clone_members(&newobj->std, &oldobj->std); @@ -179,11 +174,11 @@ static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC) { /**/ - memcpy(&obj->bbcode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - obj->bbcode_handlers.offset = XtOffsetOf(bbcode_object, std); - obj->bbcode_handlers.dtor_obj = (zend_object_dtor_obj_t) bbcode_destroy; - obj->bbcode_handlers.free_obj = (zend_object_free_obj_t) bbcode_free; - obj->bbcode_handlers.clone_obj = (zend_object_clone_obj_t) bbcode_clone; + memcpy(&bbcode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + bbcode_handlers.offset = XtOffsetOf(bbcode_object, std); + bbcode_handlers.dtor_obj = (zend_object_dtor_obj_t) bbcode_destroy; + bbcode_handlers.free_obj = (zend_object_free_obj_t) bbcode_free; + bbcode_handlers.clone_obj = (zend_object_clone_obj_t) bbcode_clone; //bbcode_handlers.offset = XtOffsetOf(bbcode_object, std); //bbcode_handlers.dtor_obj = (zend_object_dtor_obj_t) bbcode_destroy; //bbcode_handlers.free_obj = (zend_object_free_obj_t) bbcode_free; @@ -200,7 +195,7 @@ static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC) { return retval;*/ - obj->std.handlers = &(obj->bbcode_handlers); + obj->std.handlers = &bbcode_handlers; return &obj->std; }