cvs: ZendEngine2 / zend_reflection_api.c

From: Date: Mon, 01 Sep 2003 21:11:38 +0000
Subject: cvs: ZendEngine2 / zend_reflection_api.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1785@lists.php.net to get a copy of this message
helly Mon Sep 1 17:11:38 2003 EDT Modified files: /ZendEngine2 zend_reflection_api.c Log: Fix class handling of invoke Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.49 ZendEngine2/zend_reflection_api.c:1.50 --- ZendEngine2/zend_reflection_api.c:1.49 Mon Sep 1 15:47:34 2003 +++ ZendEngine2/zend_reflection_api.c Mon Sep 1 17:11:38 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.49 2003/09/01 19:47:34 helly Exp $ */ +/* $Id: zend_reflection_api.c,v 1.50 2003/09/01 21:11:38 helly Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_default_classes.h" @@ -71,25 +71,28 @@ void string_init(string *str) { - str->string = (char *) emalloc(sizeof(char)); + str->string = (char *) emalloc(1042); str->len = 1; - str->alloced = 1; + str->alloced = 1024; *str->string = '\0'; } string *string_printf(string *str, const char *format, ...) { - int n; + int len; va_list arg; char *s_tmp; va_start(arg, format); - n = zend_vspprintf(&s_tmp, 0, format, arg); - if (n) { - str->alloced += n; - str->string = erealloc(str->string, str->alloced); - memcpy(str->string + str->len - 1, s_tmp, n + 1); - str->len += n; + len = zend_vspprintf(&s_tmp, 0, format, arg); + if (len) { + register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1); + if (str->alloced < nlen) { + str->alloced = nlen; + str->string = erealloc(str->string, str->alloced); + } + memcpy(str->string + str->len - 1, s_tmp, len + 1); + str->len += len; } efree(s_tmp); va_end(arg); @@ -98,15 +101,14 @@ string *string_write(string *str, char *buf, int len) { - if (str->alloced - str->len < len) { - while (str->alloced - str->len < len) { - str->alloced *= 2; - } - str->string = erealloc(str->string, str->alloced + 1); + register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1); + if (str->alloced < nlen) { + str->alloced = nlen; + str->string = erealloc(str->string, str->alloced); } memcpy(str->string + str->len - 1, buf, len); str->len += len; - str->string[str->len] = '\0'; + str->string[str->len - 1] = '\0'; return str; } @@ -645,7 +647,7 @@ fcc.initialized = 1; fcc.function_handler = reflection_class_ptr->constructor; - fcc.calling_scope = EG(scope); + fcc.calling_scope = reflection_class_ptr; fcc.object_pp = &reflector_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); @@ -1347,6 +1349,7 @@ int result; zend_fcall_info fci; zend_fcall_info_cache fcc; + zend_class_entry *obj_ce; METHOD_NOTSTATIC; @@ -1387,9 +1390,11 @@ */ if (mptr->common.fn_flags & ZEND_ACC_STATIC) { object_pp = NULL; + obj_ce = NULL; } else { + obj_ce = Z_OBJCE_PP(params[0]); if ((Z_TYPE_PP(params[0]) != IS_OBJECT) - || (!instanceof_function(Z_OBJCE_PP(params[0]), mptr->common.scope TSRMLS_CC))) { + || (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC))) { efree(params); _DO_THROW("Given object is not an instance of the class this method was declared in"); @@ -1411,7 +1416,7 @@ fcc.initialized = 1; fcc.function_handler = mptr; - fcc.calling_scope = EG(scope); + fcc.calling_scope = obj_ce; fcc.object_pp = object_pp; result = zend_call_function(&fci, &fcc TSRMLS_CC);

« previous php.zend-engine.cvs (#1785) next »