php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_variables.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.zend.com/license/2_00.txt. |
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 | Dmitry Stogov <dmitry@php.net> |
18 +----------------------------------------------------------------------+
19*/
20
21#ifndef ZEND_VARIABLES_H
22#define ZEND_VARIABLES_H
23
24#include "zend_types.h"
25#include "zend_gc.h"
26#include "zend_hash.h"
27
29
32
33static zend_always_inline void zval_ptr_dtor_nogc(zval *zval_ptr)
34{
35 if (Z_REFCOUNTED_P(zval_ptr) && !Z_DELREF_P(zval_ptr)) {
36 rc_dtor_func(Z_COUNTED_P(zval_ptr));
37 }
38}
39
40static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr)
41{
42 if (Z_REFCOUNTED_P(zval_ptr)) {
43 zend_refcounted *ref = Z_COUNTED_P(zval_ptr);
44 if (!GC_DELREF(ref)) {
45 rc_dtor_func(ref);
46 } else {
47 gc_check_possible_root(ref);
48 }
49 }
50}
51
52static zend_always_inline void zval_copy_ctor(zval *zvalue)
53{
54 if (Z_TYPE_P(zvalue) == IS_ARRAY) {
55 ZVAL_ARR(zvalue, zend_array_dup(Z_ARR_P(zvalue)));
56 } else if (Z_REFCOUNTED_P(zvalue)) {
57 Z_ADDREF_P(zvalue);
58 }
59}
60
61static zend_always_inline void zval_opt_copy_ctor(zval *zvalue)
62{
63 if (Z_OPT_TYPE_P(zvalue) == IS_ARRAY) {
64 ZVAL_ARR(zvalue, zend_array_dup(Z_ARR_P(zvalue)));
65 } else if (Z_OPT_REFCOUNTED_P(zvalue)) {
66 Z_ADDREF_P(zvalue);
67 }
68}
69
70static zend_always_inline void zval_ptr_dtor_str(zval *zval_ptr)
71{
72 if (Z_REFCOUNTED_P(zval_ptr) && !Z_DELREF_P(zval_ptr)) {
73 ZEND_ASSERT(Z_TYPE_P(zval_ptr) == IS_STRING);
76 efree(Z_STR_P(zval_ptr));
77 }
78}
79
80ZEND_API void zval_ptr_dtor(zval *zval_ptr);
82
83/* Kept for compatibility */
84#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue)
85
87
89
90#define ZVAL_PTR_DTOR zval_ptr_dtor
91#define ZVAL_INTERNAL_PTR_DTOR zval_internal_ptr_dtor
92
93#endif
p
Definition session.c:1105
#define efree(ptr)
Definition zend_alloc.h:155
struct _zval_struct zval
#define ZEND_API
ZEND_API HashTable *ZEND_FASTCALL zend_array_dup(HashTable *source)
Definition zend_hash.c:2438
#define END_EXTERN_C()
#define zend_always_inline
#define ZEND_FASTCALL
#define ZEND_ASSERT(c)
#define BEGIN_EXTERN_C()
#define ZSTR_IS_INTERNED(s)
Definition zend_string.h:84
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define IS_STRING
Definition zend_types.h:606
#define Z_OPT_REFCOUNTED_P(zval_p)
Definition zend_types.h:944
#define Z_REFCOUNTED_P(zval_p)
Definition zend_types.h:921
#define IS_ARRAY
Definition zend_types.h:607
#define Z_COUNTED_P(zval_p)
Definition zend_types.h:699
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define GC_DELREF(p)
Definition zend_types.h:710
#define GC_FLAGS(p)
Definition zend_types.h:756
#define Z_ADDREF_P(pz)
#define ZVAL_ARR(z, a)
#define Z_DELREF_P(pz)
struct _zend_refcounted zend_refcounted
Definition zend_types.h:95
#define Z_ARR_P(zval_p)
Definition zend_types.h:984
#define IS_STR_PERSISTENT
Definition zend_types.h:818
#define Z_OPT_TYPE_P(zval_p)
Definition zend_types.h:938
ZEND_API void ZEND_FASTCALL zval_copy_ctor_func(zval *zvalue)
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
ZEND_API void ZEND_FASTCALL rc_dtor_func(zend_refcounted *p)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
ZEND_API void zval_internal_ptr_dtor(zval *zvalue)
ZEND_API void zval_add_ref(zval *p)