]> granicus.if.org Git - php/commitdiff
* Add an API macro users can use to ensure an array member can be modifed
authorZeev Suraski <zeev@php.net>
Fri, 23 Jul 1999 16:02:51 +0000 (16:02 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 23 Jul 1999 16:02:51 +0000 (16:02 +0000)
  before they modify it.
* Fix a bug and remove redundant code in convert_to_long() (booleans and
  resources weren't changing their types

Zend/zend.h
Zend/zend_operators.c

index 32bf64976c21a8afaded2458fbae058d7987cf3b..0274c212dd23e9c00014d46efd365552cf46fa4e 100644 (file)
@@ -241,8 +241,23 @@ extern zend_utility_values zend_uv;
        (z)->EA.is_ref = 0;             \
        (z)->EA.locks = 0;
 
-#define MAKE_STD_ZVAL(zv) \
+#define MAKE_STD_ZVAL(zv)                               \
        zv = (zval *) emalloc(sizeof(zval)); \
        INIT_PZVAL(zv);
 
+#define SEPARATE_ZVAL(ppzv)                                                                    \
+       {                                                                                                               \
+               zval *orig_ptr = *(ppzv);                                                       \
+                                                                                                                       \
+               if (orig_ptr->refcount>1) {                                                     \
+                       orig_ptr->refcount--;                                                   \
+                       *(ppzv) = (zval *) emalloc(sizeof(zval));               \
+                       **(ppzv) = *orig_ptr;                                                   \
+                       zval_copy_ctor(*(ppzv));                                                \
+                       (*(ppzv))->refcount=1;                                                  \
+                       (*(ppzv))->EA.is_ref = 0;                                               \
+                       (*(ppzv))->EA.locks = 0;                                                \
+               }                                                                                                       \
+       }
+
 #endif /* _ZEND_H */
index d73feecd8399b5740bac258871797da395560654..a8bd01892e0a4558a8a8c90f47772ac4bae37b7c 100644 (file)
@@ -162,34 +162,29 @@ ZEND_API void convert_to_long_base(zval *op, int base)
                case IS_BOOL:
                case IS_RESOURCE:
                case IS_LONG:
-                       return;
+                       break;
                case IS_DOUBLE:
                        op->value.lval = (long) op->value.dval;
-                       op->type = IS_LONG;
                        break;
                case IS_STRING:
                        strval = op->value.str.val;
                        op->value.lval = strtol(strval, NULL, base);
-                       op->type = IS_LONG;
                        STR_FREE(strval);
                        break;
                case IS_ARRAY:
                        tmp = (zend_hash_num_elements(op->value.ht)?1:0);
                        zval_dtor(op);
                        op->value.lval = tmp;
-                       op->type = IS_LONG;
                        break;
                case IS_OBJECT:
                        tmp = (zend_hash_num_elements(op->value.obj.properties)?1:0);
                        zval_dtor(op);
                        op->value.lval = tmp;
-                       op->type = IS_LONG;
                        break;
                default:
                        zend_error(E_WARNING, "Cannot convert to ordinal value");
                        zval_dtor(op);
                        op->value.lval = 0;
-                       op->type = IS_LONG;
                        break;
        }