X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_object.c;h=9024ee9a47b53a4d757cead7afc3c4c765d48a4b;hb=e22fc5f78e8cfc1101c4548de0568add46a8694a;hp=b8589f5aec07b5bc267f781f891c6a2048ae020d;hpb=03f11ce599fa5a89148d588caf6ccec7f939e9d4;p=m6w6%2Fext-http diff --git a/php_http_object.c b/php_http_object.c index b8589f5..9024ee9 100644 --- a/php_http_object.c +++ b/php_http_object.c @@ -12,6 +12,8 @@ #include "php_http_api.h" +static zend_object_handlers php_http_object_handlers; + zend_object *php_http_object_new(zend_class_entry *ce) { return &php_http_object_new_ex(ce, NULL)->zo; @@ -26,11 +28,17 @@ php_http_object_t *php_http_object_new_ex(zend_class_entry *ce, void *intern) object_properties_init(&o->zo, ce); o->intern = intern; - o->zo.handlers = zend_get_std_object_handlers(); + o->zo.handlers = &php_http_object_handlers; return o; } +void php_http_object_free(zend_object *object) +{ + php_http_object_t *obj = PHP_HTTP_OBJ(object, NULL); + zend_object_std_dtor(object); +} + ZEND_RESULT_CODE php_http_new(void **obj_ptr, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr) { void *obj; @@ -52,9 +60,10 @@ ZEND_RESULT_CODE php_http_new(void **obj_ptr, zend_class_entry *ce, php_http_new ZEND_RESULT_CODE php_http_method_call(zval *object, const char *method_str, size_t method_len, int argc, zval argv[], zval *retval_ptr) { zend_fcall_info fci; - zval *retval; + zval retval; ZEND_RESULT_CODE rv; + ZVAL_UNDEF(&retval); fci.size = sizeof(fci); fci.object = Z_OBJ_P(object); fci.retval = retval_ptr ? retval_ptr : &retval; @@ -68,12 +77,20 @@ ZEND_RESULT_CODE php_http_method_call(zval *object, const char *method_str, size rv = zend_call_function(&fci, NULL TSRMLS_CC); zval_ptr_dtor(&fci.function_name); - if (!retval_ptr && retval) { + if (!retval_ptr) { zval_ptr_dtor(&retval); } return rv; } +PHP_MINIT_FUNCTION(http_object) +{ + memcpy(&php_http_object_handlers, zend_get_std_object_handlers(), sizeof(php_http_object_handlers)); + php_http_object_handlers.offset = XtOffsetOf(php_http_object_t, zo); + + return SUCCESS; +} + /* * Local variables: * tab-width: 4