diff options
Diffstat (limited to 'ext/snmp/snmp.c')
-rw-r--r-- | ext/snmp/snmp.c | 62 |
1 files changed, 16 insertions, 46 deletions
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 1c781304c5..1f985316c1 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1907,26 +1907,15 @@ void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, p /* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ -zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *php_snmp_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - zval tmp_member; zval *retval; php_snmp_object *obj; php_snmp_prop_handler *hnd; int ret; - obj = Z_SNMP_P(object); - - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return &EG(uninitialized_zval); - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - } - - hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member)); + obj = php_snmp_fetch_object(object); + hnd = zend_hash_find_ptr(&php_snmp_properties, name); if (hnd && hnd->read_func) { ret = hnd->read_func(obj, rv); @@ -1936,11 +1925,7 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_ retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - } - - if (member == &tmp_member) { - zval_ptr_dtor(member); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } return retval; @@ -1949,24 +1934,13 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_ /* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ -zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *php_snmp_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zval tmp_member; php_snmp_object *obj; php_snmp_prop_handler *hnd; - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return value; - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - } - - obj = Z_SNMP_P(object); - - hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member)); + obj = php_snmp_fetch_object(object); + hnd = zend_hash_find_ptr(&php_snmp_properties, name); if (hnd && hnd->write_func) { hnd->write_func(obj, value); @@ -1977,11 +1951,7 @@ zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **ca } */ } else { - value = zend_std_write_property(object, member, value, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor(member); + value = zend_std_write_property(object, name, value, cache_slot); } return value; @@ -1990,19 +1960,19 @@ zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **ca /* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key]) Generic object property checker */ -static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) +static int php_snmp_has_property(zend_object *object, zend_string *name, int has_set_exists, void **cache_slot) { zval rv; php_snmp_prop_handler *hnd; int ret = 0; - if ((hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member))) != NULL) { + if ((hnd = zend_hash_find_ptr(&php_snmp_properties, name)) != NULL) { switch (has_set_exists) { case ZEND_PROPERTY_EXISTS: ret = 1; break; case ZEND_PROPERTY_ISSET: { - zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = php_snmp_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { ret = Z_TYPE_P(value) != IS_NULL? 1 : 0; zval_ptr_dtor(value); @@ -2010,7 +1980,7 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, break; } default: { - zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = php_snmp_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { convert_to_boolean(value); ret = Z_TYPE_P(value) == IS_TRUE? 1:0; @@ -2019,13 +1989,13 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, } } } else { - ret = zend_std_has_property(object, member, has_set_exists, cache_slot); + ret = zend_std_has_property(object, name, has_set_exists, cache_slot); } return ret; } /* }}} */ -static HashTable *php_snmp_get_gc(zval *object, zval ***gc_data, int *gc_data_count) /* {{{ */ +static HashTable *php_snmp_get_gc(zend_object *object, zval **gc_data, int *gc_data_count) /* {{{ */ { *gc_data = NULL; *gc_data_count = 0; @@ -2035,7 +2005,7 @@ static HashTable *php_snmp_get_gc(zval *object, zval ***gc_data, int *gc_data_co /* {{{ php_snmp_get_properties(zval *object) Returns all object properties. Injects SNMP properties into object on first call */ -static HashTable *php_snmp_get_properties(zval *object) +static HashTable *php_snmp_get_properties(zend_object *object) { php_snmp_object *obj; php_snmp_prop_handler *hnd; @@ -2043,7 +2013,7 @@ static HashTable *php_snmp_get_properties(zval *object) zval rv; zend_string *key; - obj = Z_SNMP_P(object); + obj = php_snmp_fetch_object(object); props = zend_std_get_properties(object); ZEND_HASH_FOREACH_STR_KEY_PTR(&php_snmp_properties, key, hnd) { |