【发布时间】:2016-11-15 05:53:43
【问题描述】:
下面的c php7 代码中的引用计数会发生什么?
在php7中zvals是在栈上创建的,所以出现引用问题:
zval destination;
array_init(destination);
{
// scope begin
zval val;
// does val's refcount incremented here or val is copied?
add_next_index_zval(destination, val);
// here the "val" will be destroyed.
// Does "destination" will experience any problems?
}
【问题讨论】:
-
很难说没有更具体的代码,但通常这很好。
val的值被复制到数组中,所以如果val变量超出范围也没关系。
标签: c php c php-internals