com php-src: Constify key access for hash and formal params: ext/opcache/ZendAccelerator.c ext/opcache/zend_accelerator_ hash.c
ext/opcache/zend_accelerator_hash.h ext/opca che/zend_persist.c ext/opcache/zend_persist.h ext/o pcache/zend_persist_calc.c

From: Date: Thu, 19 Oct 2017 10:07:08 +0000
Subject: com php-src: Constify key access for hash and formal params: ext/opcache/ZendAccelerator.c ext/opcache/zend_accelerator_ hash.c
ext/opcache/zend_accelerator_hash.h ext/opca che/zend_persist.c ext/opcache/zend_persist.h ext/o pcache/zend_persist_calc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99793@lists.php.net to get a copy of this message
Commit: f24e597c85e0c3ff64b4e4c58ccdbebb743f828b Author: Anatol Belski <ab@php.net> Thu, 19 Oct 2017 11:32:42 +0200 Parents: efcce55360e37739af56b234fa28a37d8ca15a05 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f24e597c85e0c3ff64b4e4c58ccdbebb743f828b Log: Constify key access for hash and formal params Keys created in shared memory and won't be modified and are free'd on restart. Otherwise, keys passed to functions should not be modified, too. Changed paths: M ext/opcache/ZendAccelerator.c M ext/opcache/zend_accelerator_hash.c M ext/opcache/zend_accelerator_hash.h M ext/opcache/zend_persist.c M ext/opcache/zend_persist.h M ext/opcache/zend_persist_calc.c Diff: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index d0edfa0..5e0ab19 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1281,7 +1281,7 @@ int zend_accel_invalidate(const char *filename, size_t filename_len, zend_bool f } /* Adds another key for existing cached script */ -static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_hash_entry *bucket) +static void zend_accel_add_key(const char *key, unsigned int key_length, zend_accel_hash_entry *bucket) { if (!zend_accel_hash_str_find(&ZCSG(hash), key, key_length)) { if (zend_accel_hash_is_full(&ZCSG(hash))) { @@ -1360,7 +1360,7 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script } #endif -static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length, int *from_shared_memory) +static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_script *new_persistent_script, const char *key, unsigned int key_length, int *from_shared_memory) { zend_accel_hash_entry *bucket; uint32_t memory_used; @@ -1550,7 +1550,7 @@ static void zend_accel_init_auto_globals(void) } } -static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handle, int type, char *key, zend_op_array **op_array_p) +static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handle, int type, const char *key, zend_op_array **op_array_p) { zend_persistent_script *new_persistent_script; zend_op_array *orig_active_op_array; diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index 14a83e6..f1f5c43 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -71,7 +71,7 @@ void zend_accel_hash_init(zend_accel_hash *accel_hash, uint32_t hash_size) * Returns pointer the actual hash entry on success * key needs to be already allocated as it is not copied */ -zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char *key, uint32_t key_length, zend_bool indirect, void *data) +zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, const char *key, uint32_t key_length, zend_bool indirect, void *data) { zend_ulong hash_value; zend_ulong index; @@ -140,7 +140,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char return entry; } -static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, char *key, uint32_t key_length, zend_ulong hash_value, int data) +static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, const char *key, uint32_t key_length, zend_ulong hash_value, int data) { zend_ulong index; zend_accel_hash_entry *entry; @@ -203,7 +203,7 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, z /* Returns the data associated with key on success * Returns NULL if data doesn't exist */ -void* zend_accel_hash_str_find(zend_accel_hash *accel_hash, char *key, uint32_t key_length) +void* zend_accel_hash_str_find(zend_accel_hash *accel_hash, const char *key, uint32_t key_length) { return zend_accel_hash_find_ex( accel_hash, @@ -216,7 +216,7 @@ void* zend_accel_hash_str_find(zend_accel_hash *accel_hash, char *key, uint32_t /* Returns the hash entry associated with key on success * Returns NULL if it doesn't exist */ -zend_accel_hash_entry* zend_accel_hash_str_find_entry(zend_accel_hash *accel_hash, char *key, uint32_t key_length) +zend_accel_hash_entry* zend_accel_hash_str_find_entry(zend_accel_hash *accel_hash, const char *key, uint32_t key_length) { return (zend_accel_hash_entry *)zend_accel_hash_find_ex( accel_hash, @@ -226,7 +226,7 @@ zend_accel_hash_entry* zend_accel_hash_str_find_entry(zend_accel_hash *accel_has 0); } -int zend_accel_hash_unlink(zend_accel_hash *accel_hash, char *key, uint32_t key_length) +int zend_accel_hash_unlink(zend_accel_hash *accel_hash, const char *key, uint32_t key_length) { zend_ulong hash_value; zend_ulong index; diff --git a/ext/opcache/zend_accelerator_hash.h b/ext/opcache/zend_accelerator_hash.h index 1c5b822..a7ab046 100644 --- a/ext/opcache/zend_accelerator_hash.h +++ b/ext/opcache/zend_accelerator_hash.h @@ -46,7 +46,7 @@ typedef struct _zend_accel_hash_entry zend_accel_hash_entry; struct _zend_accel_hash_entry { zend_ulong hash_value; - char *key; + const char *key; uint32_t key_length; zend_accel_hash_entry *next; void *data; @@ -66,7 +66,7 @@ void zend_accel_hash_clean(zend_accel_hash *accel_hash); zend_accel_hash_entry* zend_accel_hash_update( zend_accel_hash *accel_hash, - char *key, + const char *key, uint32_t key_length, zend_bool indirect, void *data); @@ -81,17 +81,17 @@ zend_accel_hash_entry* zend_accel_hash_find_entry( void* zend_accel_hash_str_find( zend_accel_hash *accel_hash, - char *key, + const char *key, uint32_t key_length); zend_accel_hash_entry* zend_accel_hash_str_find_entry( zend_accel_hash *accel_hash, - char *key, + const char *key, uint32_t key_length); int zend_accel_hash_unlink( zend_accel_hash *accel_hash, - char *key, + const char *key, uint32_t key_length); static inline zend_bool zend_accel_hash_is_full(zend_accel_hash *accel_hash) diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index dd68305..d2d943d 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -842,7 +842,7 @@ static void zend_accel_persist_class_table(HashTable *class_table) zend_hash_apply(class_table, (apply_func_t) zend_update_parent_ce); } -zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length) +zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, const char **key, unsigned int key_length) { script->mem = ZCG(mem); diff --git a/ext/opcache/zend_persist.h b/ext/opcache/zend_persist.h index f1a036b..154c769 100644 --- a/ext/opcache/zend_persist.h +++ b/ext/opcache/zend_persist.h @@ -23,7 +23,7 @@ #define ZEND_PERSIST_H int zend_accel_script_persistable(zend_persistent_script *script); -uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, char *key, unsigned int key_length, int for_shm); -zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, char **key, unsigned int key_length); +uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, const char *key, unsigned int key_length, int for_shm); +zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, const char **key, unsigned int key_length); #endif /* ZEND_PERSIST_H */ diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 312d0d1..fd55380 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -394,7 +394,7 @@ static void zend_accel_persist_class_table_calc(HashTable *class_table) zend_hash_persist_calc(class_table, zend_persist_class_entry_calc); } -uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, char *key, unsigned int key_length, int for_shm) +uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, const char *key, unsigned int key_length, int for_shm) { new_persistent_script->mem = NULL; new_persistent_script->size = 0;

« previous php.cvs (#99793) next »