summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-02-26 12:52:43 +0800
committerXinchen Hui <laruence@gmail.com>2014-02-26 12:52:43 +0800
commit66b7f6722d16a261243390ed2afdc97de15b5f93 (patch)
treed59b5611b79c442e471094e9c3e2951965a4d397
parent80a178015d6b162ff0ba7a8e8f5a08c88829cc3c (diff)
parent4a1ecf0e8b04363901c92aea55a203fc73a24b95 (diff)
downloadphp-git-66b7f6722d16a261243390ed2afdc97de15b5f93.tar.gz
Merge branch 'refactoring2' of github.com:zendtech/php into refactoring2
-rw-r--r--Zend/zend.c2
-rw-r--r--Zend/zend_compile.c4
-rw-r--r--Zend/zend_execute.c12
-rw-r--r--Zend/zend_execute_API.c2
-rw-r--r--Zend/zend_vm_def.h25
-rw-r--r--Zend/zend_vm_execute.h100
-rw-r--r--ext/reflection/php_reflection.c172
-rw-r--r--ext/standard/file.c4
-rw-r--r--main/streams/userspace.c172
9 files changed, 277 insertions, 216 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index f7713102e8..19401d2e03 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -228,7 +228,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
if (Z_TYPE_P(expr) == IS_REFERENCE) {
expr = Z_REFVAL_P(expr);
if (Z_TYPE_P(expr) == IS_STRING) {
- ZVAL_STR(expr_copy, Z_STR_P(expr));
+ ZVAL_STR(expr_copy, STR_COPY(Z_STR_P(expr)));
*use_copy = 1;
return;
}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index aff6cad01c..66410d41d3 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4594,8 +4594,8 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, Ha
}
return FAILURE;
} else {
- (*new_function->op_array.refcount)++;
- new_function->op_array.static_variables = NULL; /* NULL out the unbound function */
+ (*function->op_array.refcount)++;
+ function->op_array.static_variables = NULL; /* NULL out the unbound function */
return SUCCESS;
}
}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 322fe46799..9bdee5c2c1 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1383,7 +1383,7 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
{
if (Z_TYPE_P(container) != IS_OBJECT) {
if (container == &EG(error_zval)) {
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
return;
}
@@ -1398,7 +1398,7 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
object_init(container);
} else {
zend_error(E_WARNING, "Attempt to modify property of non-object");
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
return;
}
}
@@ -1408,7 +1408,8 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
if (NULL == ptr) {
if (Z_OBJ_HT_P(container)->read_property &&
(ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, key TSRMLS_CC)) != NULL) {
- ZVAL_COPY(result, ptr);
+//??? ZVAL_COPY(result, ptr);
+ ZVAL_INDIRECT(result, ptr);
} else {
zend_error_noreturn(E_ERROR, "Cannot access undefined property for object with overloaded property access");
}
@@ -1418,10 +1419,11 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
}
} else if (Z_OBJ_HT_P(container)->read_property) {
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, key TSRMLS_CC);
- ZVAL_COPY(result, ptr);
+//??? ZVAL_COPY(result, ptr);
+ ZVAL_INDIRECT(result, ptr);
} else {
zend_error(E_WARNING, "This object doesn't support property references");
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
}
}
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 863130bf29..c8679625c1 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -623,7 +623,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
}
}
- if (Z_REFCOUNT_P(element) > 1) {
+ if (Z_REFCOUNTED_P(element) && Z_REFCOUNT_P(element) > 1) {
ZVAL_DUP(&new_val, element);
/* preserve this bit for inheritance */
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index ef8817191f..b91e4894cf 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -4165,12 +4165,17 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -4180,20 +4185,28 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (IS_OP1_TMP_FREE()) { /* IS_TMP_VAR */
zval tmp;
@@ -4215,10 +4228,10 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (OP1_TYPE == IS_CONST ||
(OP1_TYPE == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(OP1_TYPE == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 7087a4e4d3..f2ebf3f7ee 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -2956,12 +2956,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = opline->op1.zv;
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -2971,20 +2976,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = opline->op1.zv;
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -3006,10 +3019,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_CONST == IS_CONST ||
(IS_CONST == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_CONST == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -7994,12 +8007,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -8009,20 +8027,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (1) { /* IS_TMP_VAR */
zval tmp;
@@ -8044,10 +8070,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_TMP_VAR == IS_CONST ||
(IS_TMP_VAR == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_TMP_VAR == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -13084,12 +13110,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -13099,20 +13130,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -13134,10 +13173,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_VAR == IS_CONST ||
(IS_VAR == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_VAR == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -29962,12 +30001,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_CV == IS_CV || IS_CV == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -29977,20 +30021,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -30012,10 +30064,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_CV == IS_CONST ||
(IS_CV == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_CV == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 5219053ec3..e82e13248e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -112,17 +112,16 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection)
/* {{{ Smart string functions */
typedef struct _string {
- char *string;
- int len;
+ zend_string *buf;
int alloced;
} string;
static void string_init(string *str)
{
- str->string = (char *) emalloc(1024);
- str->len = 1;
+ str->buf= STR_ALLOC(1024, 0);
str->alloced = 1024;
- *str->string = '\0';
+ str->buf->val[0] = '\0';
+ str->buf->len = 0;
}
static string *string_printf(string *str, const char *format, ...)
@@ -134,13 +133,15 @@ static string *string_printf(string *str, const char *format, ...)
va_start(arg, format);
len = zend_vspprintf(&s_tmp, 0, format, arg);
if (len) {
- register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1);
+ register int nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1);
if (str->alloced < nlen) {
+ int old_len = str->buf->len;
str->alloced = nlen;
- str->string = erealloc(str->string, str->alloced);
+ str->buf = STR_REALLOC(str->buf, str->alloced, 0);
+ str->buf->len = old_len;
}
- memcpy(str->string + str->len - 1, s_tmp, len + 1);
- str->len += len;
+ memcpy(str->buf->val + str->buf->len, s_tmp, len + 1);
+ str->buf->len += len;
}
efree(s_tmp);
va_end(arg);
@@ -149,31 +150,32 @@ static string *string_printf(string *str, const char *format, ...)
static string *string_write(string *str, char *buf, int len)
{
- register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1);
+ register int nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1);
if (str->alloced < nlen) {
+ int old_len = str->buf->len;
str->alloced = nlen;
- str->string = erealloc(str->string, str->alloced);
+ str->buf = STR_REALLOC(str->buf, str->alloced, 0);
+ str->buf->len = old_len;
}
- memcpy(str->string + str->len - 1, buf, len);
- str->len += len;
- str->string[str->len - 1] = '\0';
+ memcpy(str->buf->val + str->buf->len, buf, len);
+ str->buf->len += len;
+ str->buf->val[str->buf->len] = '\0';
return str;
}
static string *string_append(string *str, string *append)
{
- if (append->len > 1) {
- string_write(str, append->string, append->len - 1);
+ if (append->buf->len > 0) {
+ string_write(str, append->buf->val, append->buf->len);
}
return str;
}
static void string_free(string *str)
{
- efree(str->string);
- str->len = 0;
+ STR_RELEASE(str->buf);
str->alloced = 0;
- str->string = NULL;
+ str->buf = NULL;
}
/* }}} */
@@ -275,7 +277,7 @@ static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */
&& fptr->type == ZEND_INTERNAL_FUNCTION
&& (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0)
{
- efree((char*)fptr->internal_function.function_name);
+ STR_RELEASE(fptr->internal_function.function_name);
efree(fptr);
}
}
@@ -358,7 +360,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_write(str, "\n", 1);
}
- if (obj) {
+ if (obj && Z_TYPE_P(obj) == IS_OBJECT) {
string_printf(str, "%sObject of class [ ", indent);
} else {
char *kind = "Class";
@@ -390,28 +392,28 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
}
string_printf(str, "class ");
}
- string_printf(str, "%s", ce->name);
+ string_printf(str, "%s", ce->name->val);
if (ce->parent) {
- string_printf(str, " extends %s", ce->parent->name);
+ string_printf(str, " extends %s", ce->parent->name->val);
}
if (ce->num_interfaces) {
zend_uint i;
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
- string_printf(str, " extends %s", ce->interfaces[0]->name);
+ string_printf(str, " extends %s", ce->interfaces[0]->name->val);
} else {
- string_printf(str, " implements %s", ce->interfaces[0]->name);
+ string_printf(str, " implements %s", ce->interfaces[0]->name->val);
}
for (i = 1; i < ce->num_interfaces; ++i) {
- string_printf(str, ", %s", ce->interfaces[i]->name);
+ string_printf(str, ", %s", ce->interfaces[i]->name->val);
}
}
string_printf(str, " ] {\n");
/* The information where a class is declared is only available for user classes */
if (ce->type == ZEND_USER_CLASS) {
- string_printf(str, "%s @@ %s %d-%d\n", indent, ce->info.user.filename,
+ string_printf(str, "%s @@ %s %d-%d\n", indent, ce->info.user.filename->val,
ce->info.user.line_start, ce->info.user.line_end);
}
@@ -469,7 +471,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) {
- _property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
+ _property_string(str, prop, NULL, sub_indent.buf->val TSRMLS_CC);
}
zend_hash_move_forward_ex(&ce->properties_info, &pos);
@@ -511,7 +513,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
string_printf(str, "\n");
- _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC);
+ _function_string(str, mptr, ce, sub_indent.buf->val TSRMLS_CC);
}
zend_hash_move_forward_ex(&ce->function_table, &pos);
}
@@ -533,7 +535,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) {
- _property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
+ _property_string(str, prop, NULL, sub_indent.buf->val TSRMLS_CC);
}
zend_hash_move_forward_ex(&ce->properties_info, &pos);
}
@@ -541,7 +543,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_printf(str, "%s }\n", indent);
}
- if (obj && Z_OBJ_HT_P(obj)->get_properties) {
+ if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_properties) {
string dyn;
HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj TSRMLS_CC);
HashPosition pos;
@@ -561,7 +563,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
if (prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */
if (!zend_hash_exists(&ce->properties_info, prop_name)) {
count++;
- _property_string(&dyn, NULL, prop_name->val, sub_indent.string TSRMLS_CC);
+ _property_string(&dyn, NULL, prop_name->val, sub_indent.buf->val TSRMLS_CC);
}
}
efree(prop_name);
@@ -605,7 +607,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_function *closure;
/* see if this is a closure */
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
- && memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
+ && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
&& (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL)
{
mptr = closure;
@@ -613,7 +615,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
closure = NULL;
}
string_printf(&dyn, "\n");
- _function_string(&dyn, mptr, ce, sub_indent.string TSRMLS_CC);
+ _function_string(&dyn, mptr, ce, sub_indent.buf->val TSRMLS_CC);
count++;
_free_function(closure TSRMLS_CC);
}
@@ -833,21 +835,21 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
if (scope && fptr->common.scope) {
if (fptr->common.scope != scope) {
- string_printf(str, ", inherits %s", fptr->common.scope->name);
+ string_printf(str, ", inherits %s", fptr->common.scope->name->val);
} else if (fptr->common.scope->parent) {
lc_name_len = fptr->common.function_name->len;
lc_name = STR_ALLOC(lc_name_len, 0);
zend_str_tolower_copy(lc_name->val, fptr->common.function_name->val, lc_name_len);
if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) {
if (fptr->common.scope != overwrites->common.scope) {
- string_printf(str, ", overwrites %s", overwrites->common.scope->name);
+ string_printf(str, ", overwrites %s", overwrites->common.scope->name->val);
}
}
efree(lc_name);
}
}
if (fptr->common.prototype && fptr->common.prototype->common.scope) {
- string_printf(str, ", prototype %s", fptr->common.prototype->common.scope->name);
+ string_printf(str, ", prototype %s", fptr->common.prototype->common.scope->name->val);
}
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
string_printf(str, ", ctor");
@@ -891,20 +893,20 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
string_printf(str, "&");
}
- string_printf(str, "%s ] {\n", fptr->common.function_name);
+ string_printf(str, "%s ] {\n", fptr->common.function_name->val);
/* The information where a function is declared is only available for user classes */
if (fptr->type == ZEND_USER_FUNCTION) {
string_printf(str, "%s @@ %s %d - %d\n", indent,
- fptr->op_array.filename,
+ fptr->op_array.filename->val,
fptr->op_array.line_start,
fptr->op_array.line_end);
}
string_init(&param_indent);
string_printf(&param_indent, "%s ", indent);
if (fptr->common.fn_flags & ZEND_ACC_CLOSURE) {
- _function_closure_string(str, fptr, param_indent.string TSRMLS_CC);
+ _function_closure_string(str, fptr, param_indent.buf->val TSRMLS_CC);
}
- _function_parameter_string(str, fptr, param_indent.string TSRMLS_CC);
+ _function_parameter_string(str, fptr, param_indent.buf->val TSRMLS_CC);
string_free(&param_indent);
string_printf(str, "%s}\n", indent);
}
@@ -1071,7 +1073,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde
string str_ini;
string_init(&str_ini);
zend_hash_apply_with_arguments(EG(ini_directives) TSRMLS_CC, (apply_func_args_t) _extension_ini_string, 3, &str_ini, indent, module->module_number);
- if (str_ini.len > 1) {
+ if (str_ini.buf->len > 0) {
string_printf(str, "\n - INI {\n");
string_append(str, &str_ini);
string_printf(str, "%s }\n", indent);
@@ -1123,7 +1125,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde
string_init(&sub_indent);
string_printf(&sub_indent, "%s ", indent);
string_init(&str_classes);
- zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) _extension_class_string, 4, &str_classes, sub_indent.string, module, &num_classes);
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) _extension_class_string, 4, &str_classes, sub_indent.buf->val, module, &num_classes);
if (num_classes) {
string_printf(str, "\n - Classes [%d] {", num_classes);
string_append(str, &str_classes);
@@ -1351,10 +1353,14 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &argument_ptr, &return_output) == FAILURE) {
return;
}
+ ZVAL_COPY_VALUE(&params[0], argument_ptr);
+ ZVAL_NULL(&params[1]);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|b", &argument_ptr, &argument2_ptr, &return_output) == FAILURE) {
return;
}
+ ZVAL_COPY_VALUE(&params[0], argument_ptr);
+ ZVAL_COPY_VALUE(&params[1], argument2_ptr);
}
//??? INIT_PZVAL(&output);
@@ -1365,8 +1371,6 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
}
/* Call __construct() */
- ZVAL_COPY_VALUE(&params[0], argument_ptr);
- ZVAL_COPY_VALUE(&params[1], argument2_ptr);
fci.size = sizeof(fci);
fci.function_table = NULL;
@@ -1402,8 +1406,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
ZVAL_COPY_VALUE(&params[0], &reflector);
ZVAL_COPY_VALUE(&params[1], output_ptr);
-//??? ZVAL_STRINGL(&fname, "reflection::export", sizeof("reflection::export") - 1, 0);
- ZVAL_STRINGL(&fci.function_name, "reflection::export", sizeof("reflection::export") - 1);
+ ZVAL_STRINGL(&fci.function_name, "reflection::export", sizeof("reflection::export") - 1);
fci.function_table = &reflection_ptr->function_table;
fci.object_ptr = NULL;
fci.retval = &retval;
@@ -1413,6 +1416,8 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
result = zend_call_function(&fci, NULL TSRMLS_CC);
+ zval_ptr_dtor(&fci.function_name);
+
if (result == FAILURE && EG(exception) == NULL) {
zval_ptr_dtor(&reflector);
zval_ptr_dtor(&retval);
@@ -1640,8 +1645,7 @@ ZEND_METHOD(reflection_function, __toString)
GET_REFLECTION_OBJECT_PTR(fptr);
string_init(&str);
_function_string(&str, fptr, intern->ce, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -1871,7 +1875,6 @@ ZEND_METHOD(reflection_function, getStaticVariables)
ZEND_METHOD(reflection_function, invoke)
{
zval retval;
-//???
zval *params = NULL;
int result, num_args = 0;
zend_fcall_info fci;
@@ -1910,7 +1913,7 @@ ZEND_METHOD(reflection_function, invoke)
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Invocation of function %s() failed", fptr->common.function_name);
+ "Invocation of function %s() failed", fptr->common.function_name->val);
return;
}
@@ -1976,7 +1979,7 @@ ZEND_METHOD(reflection_function, invokeArgs)
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Invocation of function %s() failed", fptr->common.function_name);
+ "Invocation of function %s() failed", fptr->common.function_name->val);
return;
}
@@ -2207,7 +2210,7 @@ ZEND_METHOD(reflection_parameter, __construct)
is_closure = 1;
} else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME))) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Method %s::%s() does not exist", ce->name, ZEND_INVOKE_FUNC_NAME);
+ "Method %s::%s() does not exist", ce->name->val, ZEND_INVOKE_FUNC_NAME);
return;
}
}
@@ -2297,8 +2300,7 @@ ZEND_METHOD(reflection_parameter, __toString)
GET_REFLECTION_OBJECT_PTR(param);
string_init(&str);
_parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, "" TSRMLS_CC);
-///??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -2761,8 +2763,7 @@ ZEND_METHOD(reflection_method, __toString)
GET_REFLECTION_OBJECT_PTR(mptr);
string_init(&str);
_function_string(&str, mptr, intern->ce, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -2806,7 +2807,6 @@ ZEND_METHOD(reflection_method, getClosure)
ZEND_METHOD(reflection_method, invoke)
{
zval retval;
-//???
zval *params = NULL;
zval object;
reflection_object *intern;
@@ -2827,13 +2827,13 @@ ZEND_METHOD(reflection_method, invoke)
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Trying to invoke abstract method %s::%s()",
- mptr->common.scope->name, mptr->common.function_name);
+ mptr->common.scope->name->val, mptr->common.function_name->val);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Trying to invoke %s method %s::%s() from scope %s",
mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
- mptr->common.scope->name, mptr->common.function_name,
- Z_OBJCE_P(getThis())->name);
+ mptr->common.scope->name->val, mptr->common.function_name->val,
+ Z_OBJCE_P(getThis())->name->val);
}
return;
}
@@ -2895,7 +2895,7 @@ ZEND_METHOD(reflection_method, invoke)
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name);
+ "Invocation of method %s::%s() failed", mptr->common.scope->name->val, mptr->common.function_name->val);
return;
}
@@ -2936,13 +2936,13 @@ ZEND_METHOD(reflection_method, invokeArgs)
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Trying to invoke abstract method %s::%s()",
- mptr->common.scope->name, mptr->common.function_name);
+ mptr->common.scope->name->val, mptr->common.function_name->val);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Trying to invoke %s method %s::%s() from scope %s",
mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
- mptr->common.scope->name, mptr->common.function_name,
- Z_OBJCE_P(getThis())->name);
+ mptr->common.scope->name->val, mptr->common.function_name->val,
+ Z_OBJCE_P(getThis())->name->val);
}
return;
}
@@ -2967,7 +2967,7 @@ ZEND_METHOD(reflection_method, invokeArgs)
efree(params);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Trying to invoke non static method %s::%s() without an object",
- mptr->common.scope->name, mptr->common.function_name);
+ mptr->common.scope->name->val, mptr->common.function_name->val);
return;
}
@@ -3010,7 +3010,7 @@ ZEND_METHOD(reflection_method, invokeArgs)
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name);
+ "Invocation of method %s::%s() failed", mptr->common.scope->name->val, mptr->common.function_name->val);
return;
}
@@ -3244,7 +3244,7 @@ ZEND_METHOD(reflection_method, getPrototype)
if (!mptr->common.prototype) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name);
+ "Method %s::%s does not have a prototype", intern->ce->name->val, mptr->common.function_name->val);
return;
}
@@ -3506,8 +3506,7 @@ ZEND_METHOD(reflection_class, __toString)
GET_REFLECTION_OBJECT_PTR(ce);
string_init(&str);
_class_string(&str, ce, &intern->obj, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -3879,7 +3878,7 @@ ZEND_METHOD(reflection_class, getProperty)
}
if (!instanceof_function(ce, ce2 TSRMLS_CC)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name, str_name, ce->name->val);
+ zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name->val, str_name, ce->name->val);
return;
}
ce = ce2;
@@ -4193,14 +4192,13 @@ ZEND_METHOD(reflection_class, newInstance)
/* Run the constructor if there is one */
if (constructor) {
-//???
zval *params = NULL;
int num_args = 0;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name->val);
zval_dtor(return_value);
RETURN_NULL();
}
@@ -4247,7 +4245,7 @@ ZEND_METHOD(reflection_class, newInstance)
efree(params);
}
} else if (ZEND_NUM_ARGS()) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name->val);
}
}
/* }}} */
@@ -4263,7 +4261,7 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->create_object != NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name->val);
}
object_init_ex(return_value, ce);
@@ -4302,13 +4300,12 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
/* Run the constructor if there is one */
if (constructor) {
-//???
zval *params = NULL;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name->val);
zval_dtor(return_value);
RETURN_NULL();
}
@@ -4591,7 +4588,7 @@ ZEND_METHOD(reflection_class, implementsInterface)
if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Interface %s is a Class", interface_ce->name);
+ "Interface %s is a Class", interface_ce->name->val);
return;
}
RETURN_BOOL(instanceof_function(ce, interface_ce TSRMLS_CC));
@@ -4802,7 +4799,7 @@ ZEND_METHOD(reflection_property, __construct)
}
}
if (dynam_prop == 0) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s::$%s does not exist", ce->name, name_str);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s::$%s does not exist", ce->name->val, name_str);
return;
}
}
@@ -4861,8 +4858,7 @@ ZEND_METHOD(reflection_property, __toString)
GET_REFLECTION_OBJECT_PTR(ref);
string_init(&str);
_property_string(&str, &ref->prop, NULL, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -4961,7 +4957,7 @@ ZEND_METHOD(reflection_property, getValue)
if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
_default_get_entry(getThis(), "name", sizeof("name")-1, &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
+ "Cannot access non-public member %s::%s", intern->ce->name->val, Z_STRVAL(name));
zval_dtor(&name);
return;
}
@@ -5009,7 +5005,7 @@ ZEND_METHOD(reflection_property, setValue)
if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
_default_get_entry(getThis(), "name", sizeof("name")-1, &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
+ "Cannot access non-public member %s::%s", intern->ce->name->val, Z_STRVAL(name));
zval_dtor(&name);
return;
}
@@ -5203,8 +5199,7 @@ ZEND_METHOD(reflection_extension, __toString)
GET_REFLECTION_OBJECT_PTR(module);
string_init(&str);
_extension_string(&str, module, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -5278,7 +5273,7 @@ static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list
if (number == constant->module_number) {
ZVAL_DUP(&const_val, &constant->value);
//??? INIT_PZVAL(const_val);
-//???
+
add_assoc_zval_ex(retval, constant->name->val, constant->name->len, &const_val);
}
return 0;
@@ -5549,8 +5544,7 @@ ZEND_METHOD(reflection_zend_extension, __toString)
GET_REFLECTION_OBJECT_PTR(extension);
string_init(&str);
_zend_extension_string(&str, extension, "" TSRMLS_CC);
-//??? RETURN_STRINGL(str.string, str.len - 1, 0);
- RETURN_STRINGL(str.string, str.len - 1);
+ RETURN_STR(str.buf);
}
/* }}} */
@@ -6074,7 +6068,7 @@ static void _reflection_write_property(zval *object, zval *member, zval *value,
|| (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class")))))
{
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member));
+ "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name->val, Z_STRVAL_P(member));
}
else
{
diff --git a/ext/standard/file.c b/ext/standard/file.c
index c4327fab4e..ffe9b00b2b 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -764,7 +764,7 @@ PHP_FUNCTION(file)
do {
p++;
parse_eol:
- add_index_stringl(return_value, i++, estrndup(s, p-s), p-s, 0);
+ add_index_stringl(return_value, i++, s, p-s, 1);
s = p;
} while ((p = memchr(p, eol_marker, (e-p))));
} else {
@@ -777,7 +777,7 @@ parse_eol:
s = ++p;
continue;
}
- add_index_stringl(return_value, i++, estrndup(s, p-s-windows_eol), p-s-windows_eol, 0);
+ add_index_stringl(return_value, i++, s, p-s-windows_eol, 1);
s = ++p;
} while ((p = memchr(p, eol_marker, (e-p))));
}
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 9ba282ebeb..2e5e26d967 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -120,7 +120,7 @@ PHP_MINIT_FUNCTION(user_streams)
struct _php_userstream_data {
struct php_user_stream_wrapper * wrapper;
- zval * object;
+ zval object;
};
typedef struct _php_userstream_data php_userstream_data_t;
@@ -281,7 +281,7 @@ typedef struct _php_userstream_data php_userstream_data_t;
}}} **/
-static zval *user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context, zval *object TSRMLS_DC)
+static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context, zval *object TSRMLS_DC)
{
/* create an instance of our class */
object_init_ex(object, uwrap->ce);
@@ -319,18 +319,15 @@ static zval *user_stream_create_object(struct php_user_stream_wrapper *uwrap, ph
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name->val, uwrap->ce->constructor->common.function_name->val);
zval_dtor(object);
ZVAL_UNDEF(object);
- return NULL;
} else {
zval_ptr_dtor(&retval);
}
}
- return object;
}
static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
{
- zval object;
struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
php_userstream_data_t *us;
zval zretval, zfuncname;
@@ -360,8 +357,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
- us->object = user_stream_create_object(uwrap, context, &object TSRMLS_CC);
- if(us->object == NULL) {
+ user_stream_create_object(uwrap, context, &us->object TSRMLS_CC);
+ if (Z_TYPE(us->object) == IS_UNDEF) {
FG(user_stream_current_filename) = NULL;
PG(in_user_include) = old_in_user_include;
efree(us);
@@ -377,7 +374,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
ZVAL_STRING(&zfuncname, USERSTREAM_OPEN);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&zfuncname,
&zretval,
4, args,
@@ -393,7 +390,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
}
/* set wrapper data to be a reference to our object */
- ZVAL_COPY(&stream->wrapperdata, us->object);
+ ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_OPEN "\" call failed",
us->wrapper->classname);
@@ -401,15 +398,15 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
/* destroy everything else */
if (stream == NULL) {
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
}
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
- zval_ptr_dtor(&args[4]);
zval_ptr_dtor(&args[3]);
zval_ptr_dtor(&args[2]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
FG(user_stream_current_filename) = NULL;
@@ -420,7 +417,6 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char *filename, const char *mode,
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
{
- zval object;
struct php_user_stream_wrapper *uwrap = (struct php_user_stream_wrapper*)wrapper->abstract;
php_userstream_data_t *us;
zval zretval, zfuncname;
@@ -438,8 +434,8 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
us = emalloc(sizeof(*us));
us->wrapper = uwrap;
- us->object = user_stream_create_object(uwrap, context, &object TSRMLS_CC);
- if(us->object == NULL) {
+ user_stream_create_object(uwrap, context, &us->object TSRMLS_CC);
+ if (Z_TYPE(us->object) == IS_UNDEF) {
FG(user_stream_current_filename) = NULL;
efree(us);
return NULL;
@@ -452,7 +448,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&zfuncname,
&zretval,
2, args,
@@ -463,7 +459,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode);
/* set wrapper data to be a reference to our object */
- ZVAL_COPY(&stream->wrapperdata, us->object);
+ ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "\"%s::" USERSTREAM_DIR_OPEN "\" call failed",
us->wrapper->classname);
@@ -471,7 +467,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
/* destroy everything else */
if (stream == NULL) {
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
}
zval_ptr_dtor(&zretval);
@@ -596,18 +592,18 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1);
ZVAL_STRINGL(&args[0], (char*)buf, count);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args,
0, NULL TSRMLS_CC);
zval_ptr_dtor(&args[0]);
+ zval_ptr_dtor(&func_name);
didwrite = 0;
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@@ -642,13 +638,12 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1);
ZVAL_LONG(&args[0], count);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args,
@@ -672,14 +667,14 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
zval_ptr_dtor(&retval);
ZVAL_UNDEF(&retval);
+ zval_ptr_dtor(&func_name);
/* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
@@ -695,6 +690,7 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return didread;
}
@@ -707,18 +703,18 @@ static int php_userstreamop_close(php_stream *stream, int close_handle TSRMLS_DC
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&us->object);
efree(us);
@@ -734,11 +730,10 @@ static int php_userstreamop_flush(php_stream *stream TSRMLS_DC)
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
@@ -749,6 +744,7 @@ static int php_userstreamop_flush(php_stream *stream TSRMLS_DC)
call_result = -1;
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return call_result;
}
@@ -763,14 +759,13 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1);
ZVAL_LONG(&args[0], offset);
ZVAL_LONG(&args[1], whence);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
2, args,
@@ -778,6 +773,7 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&func_name);
if (call_result == FAILURE) {
/* stream_seek is not implemented, so disable seeks for this stream */
@@ -801,11 +797,10 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
}
/* now determine where we are */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
@@ -821,6 +816,7 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return ret;
}
@@ -879,11 +875,10 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb TSR
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
int ret = -1;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
@@ -899,6 +894,7 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb TSR
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return ret;
}
@@ -914,9 +910,8 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
switch (option) {
case PHP_STREAM_OPTION_CHECK_LIVENESS:
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
- call_result = call_user_function_ex(NULL, us->object, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC);
+ call_result = call_user_function_ex(NULL, &us->object, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC);
if (call_result == SUCCESS && Z_TYPE(retval) == IS_BOOL) {
ret = zval_is_true(&retval) ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
} else {
@@ -925,6 +920,8 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
us->wrapper->classname);
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
break;
case PHP_STREAM_OPTION_LOCKING:
@@ -946,11 +943,10 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
}
/* TODO wouldblock */
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
@@ -968,15 +964,17 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
}
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
+ zval_ptr_dtor(&args[0]);
break;
case PHP_STREAM_OPTION_TRUNCATE_API:
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_TRUNCATE, sizeof(USERSTREAM_TRUNCATE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_TRUNCATE, sizeof(USERSTREAM_TRUNCATE)-1);
switch (value) {
case PHP_STREAM_TRUNCATE_SUPPORTED:
- if (zend_is_callable_ex(&func_name, us->object, IS_CALLABLE_CHECK_SILENT,
+ if (zend_is_callable_ex(&func_name, &us->object, IS_CALLABLE_CHECK_SILENT,
NULL, NULL, NULL TSRMLS_CC))
ret = PHP_STREAM_OPTION_RETURN_OK;
else
@@ -988,7 +986,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) {
ZVAL_LONG(&args[0], (long)new_size);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
@@ -1006,12 +1004,15 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
"%s::" USERSTREAM_TRUNCATE " is not implemented!",
us->wrapper->classname);
}
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&args[0]);
} else { /* bad new size */
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
break;
}
}
+ zval_ptr_dtor(&func_name);
break;
case PHP_STREAM_OPTION_READ_BUFFER:
@@ -1019,7 +1020,6 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
case PHP_STREAM_OPTION_READ_TIMEOUT:
case PHP_STREAM_OPTION_BLOCKING: {
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_SET_OPTION, sizeof(USERSTREAM_SET_OPTION)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_SET_OPTION, sizeof(USERSTREAM_SET_OPTION)-1);
ZVAL_LONG(&args[0], option);
@@ -1050,7 +1050,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
}
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
3, args, 0, NULL TSRMLS_CC);
@@ -1065,17 +1065,16 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
+ zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[2]);
zval_ptr_dtor(&args[1]);
+ zval_ptr_dtor(&args[0]);
+ zval_ptr_dtor(&func_name);
break;
}
}
- /* clean up */
- zval_ptr_dtor(&retval);
- zval_ptr_dtor(&args[0]);
-
return ret;
}
@@ -1086,12 +1085,12 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
zval zfuncname, zretval;
zval args[1];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
@@ -1101,7 +1100,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_UNLINK);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
1, args,
@@ -1114,7 +1113,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&args[1]);
@@ -1130,12 +1129,12 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
@@ -1146,7 +1145,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
ZVAL_STRING(&zfuncname, USERSTREAM_RENAME);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
@@ -1159,7 +1158,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
@@ -1176,12 +1175,12 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
zval zfuncname, zretval;
zval args[3];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
@@ -1193,7 +1192,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
3, args,
@@ -1206,7 +1205,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
@@ -1224,12 +1223,12 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
@@ -1240,7 +1239,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
@@ -1253,7 +1252,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
@@ -1270,7 +1269,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
zval zfuncname, zretval;
zval args[3];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = 0;
switch(option) {
@@ -1298,8 +1297,8 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
}
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if (object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
zval_ptr_dtor(&args[2]);
return ret;
}
@@ -1311,7 +1310,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_METADATA);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
3, args,
@@ -1324,7 +1323,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
@@ -1343,12 +1342,12 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
zval zfuncname, zretval;
zval args[2];
int call_result;
- zval *object, tmp_object;
+ zval object;
int ret = -1;
/* create an instance of our class */
- object = user_stream_create_object(uwrap, context, &tmp_object TSRMLS_CC);
- if(object == NULL) {
+ user_stream_create_object(uwrap, context, &object TSRMLS_CC);
+ if (Z_TYPE(object) == IS_UNDEF) {
return ret;
}
@@ -1359,7 +1358,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_STATURL);
call_result = call_user_function_ex(NULL,
- object,
+ &object,
&zfuncname,
&zretval,
2, args,
@@ -1377,7 +1376,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
}
/* clean up */
- zval_ptr_dtor(object);
+ zval_ptr_dtor(&object);
zval_ptr_dtor(&zretval);
zval_ptr_dtor(&zfuncname);
@@ -1401,11 +1400,10 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou
if (count != sizeof(php_stream_dirent))
return 0;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1);
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL,
@@ -1422,6 +1420,7 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou
}
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return didread;
}
@@ -1434,16 +1433,17 @@ static int php_userstreamop_closedir(php_stream *stream, int close_handle TSRMLS
assert(us != NULL);
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
- zval_ptr_dtor(us->object);
+ zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
+ zval_ptr_dtor(&us->object);
efree(us);
@@ -1456,16 +1456,16 @@ static int php_userstreamop_rewinddir(php_stream *stream, off_t offset, int when
zval retval;
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1);
call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
0, NULL, 0, NULL TSRMLS_CC);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
return 0;
@@ -1481,7 +1481,6 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr T
int call_result;
int ret = FAILURE;
-//??? ZVAL_STRINGL(&func_name, USERSTREAM_CAST, sizeof(USERSTREAM_CAST)-1, 0);
ZVAL_STRINGL(&func_name, USERSTREAM_CAST, sizeof(USERSTREAM_CAST)-1);
switch(castas) {
@@ -1494,7 +1493,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr T
}
call_result = call_user_function_ex(NULL,
- us->object,
+ &us->object,
&func_name,
&retval,
1, args, 0, NULL TSRMLS_CC);
@@ -1524,6 +1523,7 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr T
} while (0);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
zval_ptr_dtor(&args[0]);
return ret;