在php5.3以前,爲某變量分配內存是用宏 MAKE_STD_ZVAL;php
737 #define MAKE_STD_ZVAL(zv) \ # /Zend/zend.h
738 ALLOC_ZVAL(zv); \
739 INIT_PZVAL(zv);ide
165 #define ALLOC_ZVAL(z) \ # /Zend/zend_alloc.h
166 (z) = (zval *) emalloc(sizeof(zval))spa
727 #define INIT_PZVAL(z) \ # /Zend/zend.h
728 (z)->refcount__gc = 1; \
729 (z)->is_ref__gc = 0;htm
php5.3以及php5.4以後 仍是用宏 MAKE_STD_ZVAL; 可是 ALLOC_ZVAL 裏面有了新的實現,是由於php5.3新的GC(垃圾回收機制)內存
#undef 是在後面取消之前定義的宏定義get
/* The following macroses override macroses from zend_alloc.h */
203 #undef ALLOC_ZVAL
204 #define ALLOC_ZVAL(z) \
205 do { \
206 (z) = (zval*)emalloc(sizeof(zval_gc_info)); \
207 GC_ZVAL_INIT(z); \
208 } while (0)變量
63 #define GC_ZVAL_INIT(z) \
64 ((zval_gc_info*)(z))->u.buffered = NULL垃圾回收
至於爲何這樣作,在 php5.3新的垃圾回收機制詳解 中有詳細的介紹gc