summaryrefslogtreecommitdiff
path: root/ext/opcache
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-06-30 04:05:24 +0300
committerDmitry Stogov <dmitry@zend.com>2015-06-30 04:05:24 +0300
commit4a2e40bb861bc3cf5fb6863e57486ed60316e97c (patch)
tree6579660b282fdd1bc50095e48d702913a0b6aa97 /ext/opcache
parent8cce5b2641fb91c3073018b59f6f044b843041a8 (diff)
downloadphp-git-4a2e40bb861bc3cf5fb6863e57486ed60316e97c.tar.gz
Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).
Diffstat (limited to 'ext/opcache')
-rw-r--r--ext/opcache/Optimizer/block_pass.c12
-rw-r--r--ext/opcache/Optimizer/compact_literals.c12
-rw-r--r--ext/opcache/Optimizer/pass1_5.c6
-rw-r--r--ext/opcache/Optimizer/zend_optimizer.c6
-rw-r--r--ext/opcache/ZendAccelerator.c76
-rw-r--r--ext/opcache/zend_accelerator_hash.c8
-rw-r--r--ext/opcache/zend_accelerator_module.c28
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c24
-rw-r--r--ext/opcache/zend_file_cache.c28
9 files changed, 100 insertions, 100 deletions
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 8b85422d2f..f4753ed080 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -38,11 +38,11 @@ int zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int
ALLOCA_FLAG(use_heap);
if ((c = zend_hash_find_ptr(EG(zend_constants), name)) == NULL) {
- lookup_name = DO_ALLOCA(name->len + 1);
- memcpy(lookup_name, name->val, name->len + 1);
- zend_str_tolower(lookup_name, name->len);
+ lookup_name = DO_ALLOCA(ZSTR_LEN(name) + 1);
+ memcpy(lookup_name, ZSTR_VAL(name), ZSTR_LEN(name) + 1);
+ zend_str_tolower(lookup_name, ZSTR_LEN(name));
- if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, name->len)) != NULL) {
+ if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, ZSTR_LEN(name))) != NULL) {
if (!(c->flags & CONST_CT_SUBST) || (c->flags & CONST_CS)) {
retval = 0;
}
@@ -906,7 +906,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline));
if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(last_op))) {
zend_string *tmp = zend_string_alloc(l, 0);
- memcpy(tmp->val, Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len);
+ memcpy(ZSTR_VAL(tmp), Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len);
Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp;
} else {
Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_extend(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0);
@@ -946,7 +946,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
l = old_len + Z_STRLEN(ZEND_OP2_LITERAL(opline));
if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(src))) {
zend_string *tmp = zend_string_alloc(l, 0);
- memcpy(tmp->val, Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len);
+ memcpy(ZSTR_VAL(tmp), Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len);
Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp;
} else {
Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_extend(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index deae12cdbb..812f24fe8f 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -422,22 +422,22 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
if (info[i].flags & LITERAL_EX_OBJ) {
int key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i]);
key = zend_string_alloc(key_len, 0);
- key->len = snprintf(key->val, key->len-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i]));
+ ZSTR_LEN(key) = snprintf(ZSTR_VAL(key), ZSTR_LEN(key)-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i]));
} else if (info[i].flags & LITERAL_EX_CLASS) {
int key_len;
zval *class_name = &op_array->literals[(info[i].u.num < i) ? map[info[i].u.num] : info[i].u.num];
key_len = Z_STRLEN_P(class_name) + sizeof("::") + Z_STRLEN(op_array->literals[i]);
key = zend_string_alloc(key_len, 0);
- memcpy(key->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name));
- memcpy(key->val + Z_STRLEN_P(class_name), "::", sizeof("::") - 1);
- memcpy(key->val + Z_STRLEN_P(class_name) + sizeof("::") - 1,
+ memcpy(ZSTR_VAL(key), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name));
+ memcpy(ZSTR_VAL(key) + Z_STRLEN_P(class_name), "::", sizeof("::") - 1);
+ memcpy(ZSTR_VAL(key) + Z_STRLEN_P(class_name) + sizeof("::") - 1,
Z_STRVAL(op_array->literals[i]),
Z_STRLEN(op_array->literals[i]) + 1);
} else {
key = zend_string_init(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0);
}
- key->h = zend_hash_func(key->val, key->len);
- key->h += info[i].flags;
+ ZSTR_H(key) = zend_hash_func(ZSTR_VAL(key), ZSTR_LEN(key));
+ ZSTR_H(key) += info[i].flags;
}
if ((info[i].flags & LITERAL_MAY_MERGE) &&
(pos = zend_hash_find(&hash, key)) != NULL &&
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 2ae6b79b50..6fcdc3e47a 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -296,7 +296,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
/* for A::B */
if (op_array->scope &&
!strncasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)),
- op_array->scope->name->val, Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) {
+ ZSTR_VAL(op_array->scope->name), Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) {
ce = op_array->scope;
} else {
if ((ce = zend_hash_find_ptr(EG(class_table),
@@ -562,8 +562,8 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
!zend_optimizer_is_disabled_func("dirname", sizeof("dirname") - 1) &&
IS_ABSOLUTE_PATH(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) {
zend_string *dirname = zend_string_init(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)), 0);
- dirname->len = zend_dirname(dirname->val, dirname->len);
- if (IS_ABSOLUTE_PATH(dirname->val, dirname->len)) {
+ ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
+ if (IS_ABSOLUTE_PATH(ZSTR_VAL(dirname), ZSTR_LEN(dirname))) {
zval t;
ZVAL_STR(&t, dirname);
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index e0dfbfa541..9ae718ede2 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -62,9 +62,9 @@ int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
while (i < op_array->last_var) {
if (op_array->vars[i] == name ||
- (op_array->vars[i]->h == hash_value &&
- op_array->vars[i]->len == name->len &&
- memcmp(op_array->vars[i]->val, name->val, name->len) == 0)) {
+ (ZSTR_H(op_array->vars[i]) == hash_value &&
+ ZSTR_LEN(op_array->vars[i]) == ZSTR_LEN(name) &&
+ memcmp(ZSTR_VAL(op_array->vars[i]), ZSTR_VAL(name), ZSTR_LEN(name)) == 0)) {
return (int)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, i);
}
i++;
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index dfcc32008d..2234d5ee56 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -295,8 +295,8 @@ static zend_string *accel_find_interned_string(zend_string *str)
arData = ZCSG(interned_strings).arData;
while (idx != HT_INVALID_IDX) {
p = HT_HASH_TO_BUCKET_EX(arData, idx);
- if ((p->h == h) && (p->key->len == str->len)) {
- if (!memcmp(p->key->val, str->val, str->len)) {
+ if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) {
+ if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) {
return p->key;
}
}
@@ -334,8 +334,8 @@ zend_string *accel_new_interned_string(zend_string *str)
idx = HT_HASH(&ZCSG(interned_strings), nIndex);
while (idx != HT_INVALID_IDX) {
p = HT_HASH_TO_BUCKET(&ZCSG(interned_strings), idx);
- if ((p->h == h) && (p->key->len == str->len)) {
- if (!memcmp(p->key->val, str->val, str->len)) {
+ if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) {
+ if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) {
zend_string_release(str);
return p->key;
}
@@ -366,9 +366,9 @@ zend_string *accel_new_interned_string(zend_string *str)
GC_TYPE(p->key) = IS_STRING;
GC_FLAGS(p->key) = IS_STR_INTERNED | IS_STR_PERMANENT;
#endif
- p->key->h = str->h;
- p->key->len = str->len;
- memcpy(p->key->val, str->val, str->len);
+ ZSTR_H(p->key) = ZSTR_H(str);
+ ZSTR_LEN(p->key) = ZSTR_LEN(str);
+ memcpy(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str));
ZVAL_INTERNED_STR(&p->val, p->key);
Z_NEXT(p->val) = HT_HASH(&ZCSG(interned_strings), nIndex);
HT_HASH(&ZCSG(interned_strings), nIndex) = HT_IDX_TO_HASH(idx);
@@ -782,7 +782,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_
case ZEND_HANDLE_FILENAME:
case ZEND_HANDLE_MAPPED:
if (file_handle->opened_path) {
- char *file_path = file_handle->opened_path->val;
+ char *file_path = ZSTR_VAL(file_handle->opened_path);
if (is_stream_path(file_path)) {
if (zend_get_stream_timestamp(file_path, &statbuf) == SUCCESS) {
@@ -847,16 +847,16 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri
*/
if (file_handle->opened_path) {
if (persistent_script->full_path != file_handle->opened_path &&
- (persistent_script->full_path->len != file_handle->opened_path->len ||
- memcmp(persistent_script->full_path->val, file_handle->opened_path->val, file_handle->opened_path->len) != 0)) {
+ (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(file_handle->opened_path) ||
+ memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(file_handle->opened_path), ZSTR_LEN(file_handle->opened_path)) != 0)) {
return FAILURE;
}
} else {
full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename));
if (full_path_ptr &&
persistent_script->full_path != full_path_ptr &&
- (persistent_script->full_path->len != full_path_ptr->len ||
- memcmp(persistent_script->full_path->val, full_path_ptr->val, full_path_ptr->len) != 0)) {
+ (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(full_path_ptr) ||
+ memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(full_path_ptr), ZSTR_LEN(full_path_ptr)) != 0)) {
zend_string_release(full_path_ptr);
return FAILURE;
}
@@ -884,7 +884,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri
}
ps_handle.type = ZEND_HANDLE_FILENAME;
- ps_handle.filename = persistent_script->full_path->val;
+ ps_handle.filename = ZSTR_VAL(persistent_script->full_path);
ps_handle.opened_path = persistent_script->full_path;
if (zend_get_file_handle_timestamp(&ps_handle, NULL) == persistent_script->timestamp) {
@@ -941,8 +941,8 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
zend_accel_error(ACCEL_LOG_INFO, "getcwd() failed for '%s' (%d), please try to set opcache.use_cwd to 0 in ini file", path, errno);
return NULL;
}
- cwd = cwd_str->val;
- cwd_len = cwd_str->len;
+ cwd = ZSTR_VAL(cwd_str);
+ cwd_len = ZSTR_LEN(cwd_str);
#ifndef ZTS
if (ZCG(cwd_check)) {
ZCG(cwd_check) = 0;
@@ -961,7 +961,7 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
}
if (str) {
char buf[32];
- char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, str->val - ZCSG(interned_strings_start));
+ char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, ZSTR_VAL(str) - ZCSG(interned_strings_start));
cwd_len = ZCG(cwd_key_len) = buf + sizeof(buf) - 1 - res;
cwd = ZCG(cwd_key);
@@ -975,12 +975,12 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
if (EXPECTED(ZCG(include_path_key_len))) {
include_path = ZCG(include_path_key);
include_path_len = ZCG(include_path_key_len);
- } else if (!ZCG(include_path) || ZCG(include_path)->len == 0) {
+ } else if (!ZCG(include_path) || ZSTR_LEN(ZCG(include_path)) == 0) {
include_path = "";
include_path_len = 0;
} else {
- include_path = ZCG(include_path)->val;
- include_path_len = ZCG(include_path)->len;
+ include_path = ZSTR_VAL(ZCG(include_path));
+ include_path_len = ZSTR_LEN(ZCG(include_path));
#ifndef ZTS
if (ZCG(include_path_check)) {
@@ -1000,7 +1000,7 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
}
if (str) {
char buf[32];
- char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, str->val - ZCSG(interned_strings_start));
+ char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, ZSTR_VAL(str) - ZCSG(interned_strings_start));
include_path_len = ZCG(include_path_key_len) = buf + sizeof(buf) - 1 - res;
include_path = ZCG(include_path_key);
@@ -1041,15 +1041,15 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
if (EXPECTED(EG(current_execute_data)) &&
EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) {
- parent_script_len = parent_script->len;
- while ((--parent_script_len > 0) && !IS_SLASH(parent_script->val[parent_script_len]));
+ parent_script_len = ZSTR_LEN(parent_script);
+ while ((--parent_script_len > 0) && !IS_SLASH(ZSTR_VAL(parent_script)[parent_script_len]));
if (UNEXPECTED((size_t)(key_length + parent_script_len + 1) >= sizeof(ZCG(key)))) {
return NULL;
}
ZCG(key)[key_length] = ':';
key_length += 1;
- memcpy(ZCG(key) + key_length, parent_script->val, parent_script_len);
+ memcpy(ZCG(key) + key_length, ZSTR_VAL(parent_script), parent_script_len);
key_length += parent_script_len;
}
ZCG(key)[key_length] = '\0';
@@ -1097,7 +1097,7 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc
zend_file_handle file_handle;
file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = realpath->val;
+ file_handle.filename = ZSTR_VAL(realpath);
file_handle.opened_path = realpath;
if (force ||
@@ -1183,15 +1183,15 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script
new_persistent_script->is_phar =
new_persistent_script->full_path &&
- strstr(new_persistent_script->full_path->val, ".phar") &&
- !strstr(new_persistent_script->full_path->val, "://");
+ strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") &&
+ !strstr(ZSTR_VAL(new_persistent_script->full_path), "://");
/* Consistency check */
if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) {
zend_accel_error(
((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING,
"Internal error: wrong size calculation: %s start=0x%08x, end=0x%08x, real=0x%08x\n",
- new_persistent_script->full_path->val,
+ ZSTR_VAL(new_persistent_script->full_path),
new_persistent_script->mem,
(char *)new_persistent_script->mem + new_persistent_script->size,
ZCG(mem));
@@ -1277,15 +1277,15 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
new_persistent_script->is_phar =
new_persistent_script->full_path &&
- strstr(new_persistent_script->full_path->val, ".phar") &&
- !strstr(new_persistent_script->full_path->val, "://");
+ strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") &&
+ !strstr(ZSTR_VAL(new_persistent_script->full_path), "://");
/* Consistency check */
if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) {
zend_accel_error(
((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING,
"Internal error: wrong size calculation: %s start=0x%08x, end=0x%08x, real=0x%08x\n",
- new_persistent_script->full_path->val,
+ ZSTR_VAL(new_persistent_script->full_path),
new_persistent_script->mem,
(char *)new_persistent_script->mem + new_persistent_script->size,
ZCG(mem));
@@ -1294,14 +1294,14 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script);
/* store script structure in the hash table */
- bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len, 0, new_persistent_script);
+ bucket = zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(new_persistent_script->full_path), ZSTR_LEN(new_persistent_script->full_path), 0, new_persistent_script);
if (bucket) {
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path);
if (key &&
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
- (new_persistent_script->full_path->len != key_length ||
- memcmp(new_persistent_script->full_path->val, key, key_length) != 0)) {
+ (ZSTR_LEN(new_persistent_script->full_path) != key_length ||
+ memcmp(ZSTR_VAL(new_persistent_script->full_path), key, key_length) != 0)) {
/* link key to the same persistent script in hash table */
if (zend_accel_hash_update(&ZCSG(hash), key, key_length, 1, bucket)) {
zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", key);
@@ -1421,7 +1421,7 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
}
/* check blacklist right after ensuring that file was opened */
- if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, file_handle->opened_path->val)) {
+ if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, ZSTR_VAL(file_handle->opened_path))) {
ZCSG(blacklist_misses)++;
*op_array_p = accelerator_orig_compile_file(file_handle, type);
return NULL;
@@ -1577,10 +1577,10 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
/* ext/phar has to load phar's metadata into memory */
if (persistent_script->is_phar) {
php_stream_statbuf ssb;
- char *fname = emalloc(sizeof("phar://") + persistent_script->full_path->len);
+ char *fname = emalloc(sizeof("phar://") + ZSTR_LEN(persistent_script->full_path));
memcpy(fname, "phar://", sizeof("phar://") - 1);
- memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path->val, persistent_script->full_path->len + 1);
+ memcpy(fname + sizeof("phar://") - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path) + 1);
php_stream_stat_path(fname, &ssb);
efree(fname);
}
@@ -1826,10 +1826,10 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
/* ext/phar has to load phar's metadata into memory */
if (persistent_script->is_phar) {
php_stream_statbuf ssb;
- char *fname = emalloc(sizeof("phar://") + persistent_script->full_path->len);
+ char *fname = emalloc(sizeof("phar://") + ZSTR_LEN(persistent_script->full_path));
memcpy(fname, "phar://", sizeof("phar://") - 1);
- memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path->val, persistent_script->full_path->len + 1);
+ memcpy(fname + sizeof("phar://") - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path) + 1);
php_stream_stat_path(fname, &ssb);
efree(fname);
}
diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c
index dd52de3dc5..a1fadd46c9 100644
--- a/ext/opcache/zend_accelerator_hash.c
+++ b/ext/opcache/zend_accelerator_hash.c
@@ -172,8 +172,8 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
{
return zend_accel_hash_find_ex(
accel_hash,
- key->val,
- key->len,
+ ZSTR_VAL(key),
+ ZSTR_LEN(key),
zend_string_hash_val(key),
1);
}
@@ -185,8 +185,8 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, z
{
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(
accel_hash,
- key->val,
- key->len,
+ ZSTR_VAL(key),
+ ZSTR_LEN(key),
zend_string_hash_val(key),
0);
}
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 531ea6e9ed..eb93f59413 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -112,7 +112,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (zend_long *) (base + (size_t)mh_arg1);
- memsize = atoi(new_value->val);
+ memsize = atoi(ZSTR_VAL(new_value));
/* sanity check we must use at least 8 MB */
if (memsize < 8) {
const char *new_new_value = "8";
@@ -148,7 +148,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (zend_long *) (base + (size_t)mh_arg1);
- size = atoi(new_value->val);
+ size = atoi(ZSTR_VAL(new_value));
/* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */
if (size < MIN_ACCEL_FILES || size > MAX_ACCEL_FILES) {
@@ -192,7 +192,7 @@ static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (double *) (base + (size_t)mh_arg1);
- percentage = atoi(new_value->val);
+ percentage = atoi(ZSTR_VAL(new_value));
if (percentage <= 0 || percentage > 50) {
const char *new_new_value = "5";
@@ -228,10 +228,10 @@ static ZEND_INI_MH(OnEnable)
#endif
p = (zend_bool *) (base+(size_t) mh_arg1);
- if ((new_value->len == 2 && strcasecmp("on", new_value->val) == 0) ||
- (new_value->len == 3 && strcasecmp("yes", new_value->val) == 0) ||
- (new_value->len == 4 && strcasecmp("true", new_value->val) == 0) ||
- atoi(new_value->val) != 0) {
+ if ((ZSTR_LEN(new_value) == 2 && strcasecmp("on", ZSTR_VAL(new_value)) == 0) ||
+ (ZSTR_LEN(new_value) == 3 && strcasecmp("yes", ZSTR_VAL(new_value)) == 0) ||
+ (ZSTR_LEN(new_value) == 4 && strcasecmp("true", ZSTR_VAL(new_value)) == 0) ||
+ atoi(ZSTR_VAL(new_value)) != 0) {
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " can't be temporary enabled (it may be only disabled till the end of request)");
return FAILURE;
} else {
@@ -246,18 +246,18 @@ static ZEND_INI_MH(OnEnable)
static ZEND_INI_MH(OnUpdateFileCache)
{
if (new_value) {
- if (!new_value->len) {
+ if (!ZSTR_LEN(new_value)) {
new_value = NULL;
} else {
zend_stat_t buf;
- if (!IS_ABSOLUTE_PATH(new_value->val, new_value->len) ||
- zend_stat(new_value->val, &buf) != 0 ||
+ if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) ||
+ zend_stat(ZSTR_VAL(new_value), &buf) != 0 ||
!S_ISDIR(buf.st_mode) ||
#ifndef ZEND_WIN32
- access(new_value->val, R_OK | W_OK | X_OK) != 0) {
+ access(ZSTR_VAL(new_value), R_OK | W_OK | X_OK) != 0) {
#else
- _access(new_value->val, 06) != 0) {
+ _access(ZSTR_VAL(new_value), 06) != 0) {
#endif
zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n");
new_value = NULL;
@@ -316,13 +316,13 @@ static int filename_is_in_cache(zend_string *filename)
char *key;
int key_length;
- key = accel_make_persistent_key(filename->val, filename->len, &key_length);
+ key = accel_make_persistent_key(ZSTR_VAL(filename), ZSTR_LEN(filename), &key_length);
if (key != NULL) {
zend_persistent_script *persistent_script = zend_accel_hash_str_find(&ZCSG(hash), key, key_length);
if (persistent_script && !persistent_script->corrupted) {
zend_file_handle handle = {{0}, NULL, NULL, 0, 0};
- handle.filename = filename->val;
+ handle.filename = ZSTR_VAL(filename);
handle.type = ZEND_HANDLE_FILENAME;
if (ZCG(accel_directives).validate_timestamps) {
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 996deecbb2..a737e8db6b 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -534,7 +534,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) {
- if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) {
+ if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key */
t = zend_hash_update(target, p->key, &p->val);
} else {
@@ -556,11 +556,11 @@ failure:
if (function2->type == ZEND_USER_FUNCTION
&& function2->op_array.last > 0) {
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
- function1->common.function_name->val,
- function2->op_array.filename->val,
+ ZSTR_VAL(function1->common.function_name),
+ ZSTR_VAL(function2->op_array.filename),
(int)function2->op_array.opcodes[0].lineno);
} else {
- zend_error(E_ERROR, "Cannot redeclare %s()", function1->common.function_name->val);
+ zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
}
}
@@ -578,7 +578,7 @@ static void zend_accel_function_hash_copy_from_shm(HashTable *target, HashTable
ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) {
- if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) {
+ if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key */
zend_hash_update_ptr(target, p->key, ARENA_REALLOC(Z_PTR(p->val)));
} else {
@@ -600,11 +600,11 @@ failure:
if (function2->type == ZEND_USER_FUNCTION
&& function2->op_array.last > 0) {
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
- function1->common.function_name->val,
- function2->op_array.filename->val,
+ ZSTR_VAL(function1->common.function_name),
+ ZSTR_VAL(function2->op_array.filename),
(int)function2->op_array.opcodes[0].lineno);
} else {
- zend_error(E_ERROR, "Cannot redeclare %s()", function1->common.function_name->val);
+ zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
}
}
@@ -622,7 +622,7 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source, uni
ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) {
- if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) {
+ if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) {
/* Mangled key - ignore and wait for runtime */
continue;
} else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) {
@@ -643,7 +643,7 @@ failure:
CG(in_compilation) = 1;
zend_set_compiled_filename(ce1->info.user.filename);
CG(zend_lineno) = ce1->info.user.line_start;
- zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce1), ce1->name->val);
+ zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce1), ZSTR_VAL(ce1->name));
}
#ifdef __SSE2__
@@ -713,9 +713,9 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
zend_string *name;
char haltoff[] = "__COMPILER_HALT_OFFSET__";
- name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, persistent_script->full_path->val, persistent_script->full_path->len, 0);
+ name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path), 0);
if (!zend_hash_exists(EG(zend_constants), name)) {
- zend_register_long_constant(name->val, name->len, persistent_script->compiler_halt_offset, CONST_CS, 0);
+ zend_register_long_constant(ZSTR_VAL(name), ZSTR_LEN(name), persistent_script->compiler_halt_offset, CONST_CS, 0);
}
zend_string_release(name);
}
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 598e52a73d..0781b91c9d 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -202,14 +202,14 @@ static void *zend_file_cache_serialize_interned(zend_string *str,
len = ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str)));
ret = (void*)(info->str_size | Z_UL(1));
zend_shared_alloc_register_xlat_entry(str, ret);
- if (info->str_size + len > ((zend_string*)ZCG(mem))->len) {
+ if (info->str_size + len > ZSTR_LEN((zend_string*)ZCG(mem))) {
size_t new_len = info->str_size + len;
ZCG(mem) = (void*)zend_string_realloc(
(zend_string*)ZCG(mem),
((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1),
0);
}
- memcpy(((zend_string*)ZCG(mem))->val + info->str_size, str, len);
+ memcpy(ZSTR_VAL((zend_string*)ZCG(mem)) + info->str_size, str, len);
info->str_size += len;
return ret;
}
@@ -677,12 +677,12 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
void *mem, *buf;
len = strlen(ZCG(accel_directives).file_cache);
- filename = emalloc(len + 33 + script->full_path->len + sizeof(SUFFIX));
+ filename = emalloc(len + 33 + ZSTR_LEN(script->full_path) + sizeof(SUFFIX));
memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32);
- memcpy(filename + len + 33, script->full_path->val, script->full_path->len);
- memcpy(filename + len + 33 + script->full_path->len, SUFFIX, sizeof(SUFFIX));
+ memcpy(filename + len + 33, ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path));
+ memcpy(filename + len + 33 + ZSTR_LEN(script->full_path), SUFFIX, sizeof(SUFFIX));
if (zend_file_cache_mkdir(filename, len) != SUCCESS) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot create directory for file '%s'\n", filename);
@@ -730,14 +730,14 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
zend_shared_alloc_destroy_xlat_table();
info.checksum = zend_adler32(ADLER32_INIT, buf, script->size);
- info.checksum = zend_adler32(info.checksum, (signed char*)((zend_string*)ZCG(mem))->val, info.str_size);
+ info.checksum = zend_adler32(info.checksum, (signed char*)ZSTR_VAL((zend_string*)ZCG(mem)), info.str_size);
#ifndef ZEND_WIN32
vec[0].iov_base = &info;
vec[0].iov_len = sizeof(info);
vec[1].iov_base = buf;
vec[1].iov_len = script->size;
- vec[2].iov_base = ((zend_string*)ZCG(mem))->val;
+ vec[2].iov_base = ZSTR_VAL((zend_string*)ZCG(mem));
vec[2].iov_len = info.str_size;
if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + info.str_size)) {
@@ -1177,12 +1177,12 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl
return NULL;
}
len = strlen(ZCG(accel_directives).file_cache);
- filename = emalloc(len + 33 + full_path->len + sizeof(SUFFIX));
+ filename = emalloc(len + 33 + ZSTR_LEN(full_path) + sizeof(SUFFIX));
memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32);
- memcpy(filename + len + 33, full_path->val, full_path->len);
- memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX));
+ memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path));
+ memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX));
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0) {
@@ -1316,7 +1316,7 @@ use_process_mem:
if (cache_it) {
script->dynamic_members.checksum = zend_accel_script_checksum(script);
- zend_accel_hash_update(&ZCSG(hash), script->full_path->val, script->full_path->len, 0, script);
+ zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path), 0, script);
zend_shared_alloc_unlock();
zend_arena_release(&CG(arena), checkpoint);
@@ -1332,12 +1332,12 @@ void zend_file_cache_invalidate(zend_string *full_path)
char *filename;
len = strlen(ZCG(accel_directives).file_cache);
- filename = emalloc(len + 33 + full_path->len + sizeof(SUFFIX));
+ filename = emalloc(len + 33 + ZSTR_LEN(full_path) + sizeof(SUFFIX));
memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32);
- memcpy(filename + len + 33, full_path->val, full_path->len);
- memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX));
+ memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path));
+ memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX));
unlink(filename);
efree(filename);