com php-src: build_runtime_definition_key returns zen d_string*: Zend/zend_compile.c
| From: | Nikita Popov | Date: | Tue, 29 Jul 2014 18:01:11 +0000 |
| Subject: | com php-src: build_runtime_definition_key returns zen d_string*: Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-80887@lists.php.net to get a copy of this message | ||
Commit: 438b1e3d42a5605bfa12a9282590894205c9b057
Author: Nikita Popov <nikic@php.net> Tue, 29 Jul 2014 20:01:11 +0200
Parents: 18f068077994774267912b6694bf1e4aae3eaa7b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=438b1e3d42a5605bfa12a9282590894205c9b057
Log:
build_runtime_definition_key returns zend_string*
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 2b4055c..a144c6d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -153,13 +153,14 @@ static zend_string *zend_new_interned_string_safe(zend_string *str TSRMLS_DC)
{
}
}
-static void build_runtime_defined_function_key(zval *result, zend_string *name, unsigned char
*lex_pos TSRMLS_DC) /* {{{ */
-{
+static zend_string *zend_build_runtime_definition_key(
+ zend_string *name, unsigned char *lex_pos TSRMLS_DC
+) {
+ zend_string *result;
char char_pos_buf[32];
- uint char_pos_len;
- const char *filename;
+ size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
- char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
+ const char *filename;
if (CG(active_op_array)->filename) {
filename = CG(active_op_array)->filename->val;
} else {
@@ -167,13 +168,12 @@ static void build_runtime_defined_function_key(zval *result, zend_string
*name,
}
/* NULL, name length, filename length, last accepting char position length */
- ZVAL_NEW_STR(result, STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0));
+ result = STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0);
- /* must be binary safe */
- Z_STRVAL_P(result)[0] = '\0';
- sprintf(Z_STRVAL_P(result)+1, "%s%s%s", name->val, filename, char_pos_buf);
+ result->val[0] = '\0';
+ sprintf(result->val + 1, "%s%s%s", name->val, filename, char_pos_buf);
+ return result;
}
-/* }}} */
static void init_compiler_declarables(TSRMLS_D) /* {{{ */
{
@@ -5547,13 +5547,12 @@ static void zend_begin_func_decl(
}
{
- zval key;
- build_runtime_defined_function_key(&key, lcname, decl->lex_pos TSRMLS_CC);
+ zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos TSRMLS_CC);
opline->op1_type = IS_CONST;
- opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
+ LITERAL_STR(opline->op1, key);
- zend_hash_update_ptr(CG(function_table), Z_STR(key), op_array);
+ zend_hash_update_ptr(CG(function_table), key, op_array);
}
STR_RELEASE(lcname);
@@ -5973,12 +5972,12 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
}
{
- zval key;
- build_runtime_defined_function_key(&key, lcname, decl->lex_pos TSRMLS_CC);
+ zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos TSRMLS_CC);
+
opline->op1_type = IS_CONST;
- opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
+ LITERAL_STR(opline->op1, key);
- zend_hash_update_ptr(CG(class_table), Z_STR(key), ce);
+ zend_hash_update_ptr(CG(class_table), key, ce);
}
CG(active_class_entry) = ce;