diff options
| author | Marcus Boerger <helly@php.net> | 2003-08-24 17:32:47 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2003-08-24 17:32:47 +0000 |
| commit | 19ec7a09fc332d1430bd1488861ef72cb227fca6 (patch) | |
| tree | 4daef239378b7fc77c1e0bc952aea7c77dc04dc6 /Zend/zend_API.c | |
| parent | cec053f70763e9974b48836e37adcc03a8f052b6 (diff) | |
| download | php-git-19ec7a09fc332d1430bd1488861ef72cb227fca6.tar.gz | |
- Provide appropriate way to destroy internal zval's.
- Allow internal zval's of type string and disallow complex types.
- Define the default string for extensions at class level instead of ctor.
Diffstat (limited to 'Zend/zend_API.c')
| -rw-r--r-- | Zend/zend_API.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3451f0ff5a..53f7d48219 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1629,6 +1629,16 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_le } else { target_symbol_table = &ce->default_properties; } + switch(Z_TYPE_P(property)) { + case IS_ARRAY: + case IS_CONSTANT_ARRAY: + case IS_OBJECT: + case IS_RESOURCE: + zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources"); + break; + default: + break; + } switch (access_type & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PRIVATE: { char *priv_name; @@ -1691,6 +1701,21 @@ ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int na return zend_declare_property(ce, name, name_length, property, access_type); } +ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type) +{ + zval *property; + int len = strlen(value); + + if (ce->type & ZEND_INTERNAL_CLASS) { + property = malloc(sizeof(zval)); + } else { + ALLOC_ZVAL(property); + } + INIT_PZVAL(property); + ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + return zend_declare_property(ce, name, name_length, property, access_type); +} + ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC) { zval property; |
