#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;
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;
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;
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