]> granicus.if.org Git - php/commitdiff
Use interned strings for "magic" property of internal classes. (not copyied into...
authorDmitry Stogov <dmitry@zend.com>
Wed, 1 Nov 2017 16:04:54 +0000 (19:04 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 1 Nov 2017 16:04:54 +0000 (19:04 +0300)
ext/dom/php_dom.c
ext/mysqli/mysqli.c
ext/snmp/snmp.c
ext/xmlreader/php_xmlreader.c
ext/zip/php_zip.c

index 00c8b40cb378bd4c06709ad852154d7f6278c93c..8fdf6aa6e0b7de3658a78511c45ca69f6a11e794 100644 (file)
@@ -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);
 }
 /* }}} */
 
index 63065b5e9053851bb09f7cf6b5af3d3bf0621345..58d55fe3011d25dc4d554c24fcf6190844c343bc 100644 (file)
@@ -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));
index d9a49fb01b40c434089c9aef99a2e7b7bd0452d6..a622dd05747dc419b29ba8469581809f595c3388 100644 (file)
@@ -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);
 }
 /* }}} */
 
index 40b7d462cd5c54fe914dc885daf041ad6d0b6d71..392d9b19c36b881ca07169d4cdd3b7b0a7c48018 100644 (file)
@@ -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);
 }
 /* }}} */
 
index d50c73584597d6ebaf706f1b0a5c0eeda530a4bd..b5df2481e560ed897b54f44ed23b5f62e37400bc 100644 (file)
@@ -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);
 }
 /* }}} */