diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-11-01 19:04:54 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-11-01 19:04:54 +0300 |
commit | e2589b7d029cfe78316222493827876432cc1b88 (patch) | |
tree | cfe603900c88c8946ad7515217ac7c44f3f3bf60 /ext | |
parent | 990d8092a4d09648f885a71389156217e5a13db3 (diff) | |
download | php-git-e2589b7d029cfe78316222493827876432cc1b88.tar.gz |
Use interned strings for "magic" property of internal classes. (not copyied into SHM)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dom/php_dom.c | 5 | ||||
-rw-r--r-- | ext/mysqli/mysqli.c | 2 | ||||
-rw-r--r-- | ext/snmp/snmp.c | 5 | ||||
-rw-r--r-- | ext/xmlreader/php_xmlreader.c | 5 | ||||
-rw-r--r-- | ext/zip/php_zip.c | 9 |
5 files changed, 20 insertions, 6 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 00c8b40cb3..8fdf6aa6e0 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -302,10 +302,13 @@ static int dom_write_na(dom_object *obj, zval *newval) static void dom_register_prop_handler(HashTable *prop_handler, char *name, size_t name_len, dom_read_t read_func, dom_write_t write_func) { dom_prop_handler hnd; + zend_string *str; hnd.read_func = read_func ? read_func : dom_read_na; hnd.write_func = write_func ? write_func : dom_write_na; - zend_hash_str_add_mem(prop_handler, name, name_len, &hnd, sizeof(dom_prop_handler)); + str = zend_string_init_interned(name, name_len, 1); + zend_hash_add_mem(prop_handler, str, &hnd, sizeof(dom_prop_handler)); + zend_string_release(str); } /* }}} */ diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 63065b5e90..58d55fe301 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -370,7 +370,7 @@ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysqli_read_t r_func, mysqli_write_t w_func) { mysqli_prop_handler p; - p.name = zend_string_init(pname, pname_len, 1); + p.name = zend_string_init_interned(pname, pname_len, 1); p.read_func = (r_func) ? r_func : mysqli_read_na; p.write_func = (w_func) ? w_func : mysqli_write_na; zend_hash_add_mem(h, p.name, &p, sizeof(mysqli_prop_handler)); diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index d9a49fb01b..a622dd0574 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1899,12 +1899,15 @@ PHP_METHOD(snmp, getError) void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, php_snmp_read_t read_func, php_snmp_write_t write_func) { php_snmp_prop_handler p; + zend_string *str; p.name = (char*) name; p.name_length = name_length; p.read_func = (read_func) ? read_func : NULL; p.write_func = (write_func) ? write_func : NULL; - zend_hash_str_add_mem(h, (char *)name, name_length, &p, sizeof(php_snmp_prop_handler)); + str = zend_string_init_interned(name, name_length, 1); + zend_hash_add_mem(h, str, &p, sizeof(php_snmp_prop_handler)); + zend_string_release(str); } /* }}} */ diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 40b7d462cd..392d9b19c3 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -61,11 +61,14 @@ typedef struct _xmlreader_prop_handler { static void xmlreader_register_prop_handler(HashTable *prop_handler, char *name, xmlreader_read_int_t read_int_func, xmlreader_read_const_char_t read_char_func, int rettype) { xmlreader_prop_handler hnd; + zend_string *str; hnd.read_char_func = read_char_func; hnd.read_int_func = read_int_func; hnd.type = rettype; - zend_hash_str_add_mem(prop_handler, name, strlen(name), &hnd, sizeof(xmlreader_prop_handler)); + str = zend_string_init_interned(name, strlen(name), 1); + zend_hash_add_mem(prop_handler, str, &hnd, sizeof(xmlreader_prop_handler)); + zend_string_release(str); } /* }}} */ diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index d50c735845..b5df2481e5 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -800,15 +800,20 @@ typedef struct _zip_prop_handler { static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, zip_read_int_t read_int_func, zip_read_const_char_t read_char_func, zip_read_const_char_from_ze_t read_char_from_obj_func, int rettype) /* {{{ */ { zip_prop_handler hnd; + zend_string *str; + zval tmp; hnd.read_const_char_func = read_char_func; hnd.read_int_func = read_int_func; hnd.read_const_char_from_obj_func = read_char_from_obj_func; hnd.type = rettype; - zend_hash_str_add_mem(prop_handler, name, strlen(name), &hnd, sizeof(zip_prop_handler)); + str = zend_string_init_interned(name, strlen(name), 1); + zend_hash_add_mem(prop_handler, str, &hnd, sizeof(zip_prop_handler)); /* Register for reflection */ - zend_declare_property_null(zip_class_entry, name, strlen(name), ZEND_ACC_PUBLIC); + ZVAL_NULL(&tmp); + zend_declare_property_ex(zip_class_entry, str, &tmp, ZEND_ACC_PUBLIC, NULL); + zend_string_release(str); } /* }}} */ |