5
5
#include "php_agent.h"
6
6
#include "php_hash.h"
7
7
8
- #ifdef PHP7
9
8
static int nr_php_zend_hash_ptr_apply_wrapper (zval * value ,
10
9
int num_args ,
11
10
va_list args ,
@@ -24,26 +23,6 @@ static int nr_php_zend_hash_ptr_apply_wrapper(zval* value,
24
23
25
24
return (apply_func )(Z_PTR_P (value ), arg , hash_key TSRMLS_CC );
26
25
}
27
- #else
28
- static int nr_php_zend_hash_ptr_apply_wrapper (void * value TSRMLS_DC ,
29
- int num_args ,
30
- va_list args ,
31
- zend_hash_key * hash_key ) {
32
- nr_php_ptr_apply_t apply_func ;
33
- void * arg ;
34
-
35
- (void )num_args ;
36
-
37
- apply_func = (nr_php_ptr_apply_t )va_arg (args , nr_php_ptr_apply_t );
38
- arg = (void * )va_arg (args , void * );
39
-
40
- if (NULL == value ) {
41
- return ZEND_HASH_APPLY_KEEP ;
42
- }
43
-
44
- return (apply_func )(value , arg , hash_key TSRMLS_CC );
45
- }
46
- #endif /* PHP7 */
47
26
48
27
void nr_php_zend_hash_ptr_apply (HashTable * ht ,
49
28
nr_php_ptr_apply_t apply_func ,
@@ -53,7 +32,6 @@ void nr_php_zend_hash_ptr_apply(HashTable* ht,
53
32
apply_func , arg );
54
33
}
55
34
56
- #ifdef PHP7
57
35
static int nr_php_zend_hash_zval_apply_wrapper (zval * value ,
58
36
int num_args ,
59
37
va_list args ,
@@ -68,28 +46,6 @@ static int nr_php_zend_hash_zval_apply_wrapper(zval* value,
68
46
69
47
return (apply_func )(value , arg , hash_key TSRMLS_CC );
70
48
}
71
- #else
72
- static int nr_php_zend_hash_zval_apply_wrapper (zval * * value TSRMLS_DC ,
73
- int num_args ,
74
- va_list args ,
75
- zend_hash_key * hash_key ) {
76
- nr_php_zval_apply_t apply_func ;
77
- void * arg ;
78
-
79
- (void )num_args ;
80
-
81
- apply_func = (nr_php_zval_apply_t )va_arg (args , nr_php_zval_apply_t );
82
- arg = (void * )va_arg (args , void * );
83
-
84
- if ((NULL == value ) || (NULL == * value )) {
85
- return ZEND_HASH_APPLY_KEEP ;
86
- }
87
-
88
- (void )num_args ;
89
-
90
- return (apply_func )(* value , arg , hash_key TSRMLS_CC );
91
- }
92
- #endif /* PHP7 */
93
49
94
50
void nr_php_zend_hash_zval_apply (HashTable * ht ,
95
51
nr_php_zval_apply_t apply_func ,
@@ -104,17 +60,13 @@ int nr_php_zend_hash_del(HashTable* ht, const char* key) {
104
60
return 0 ;
105
61
}
106
62
107
- #ifdef PHP7
108
63
int retval ;
109
64
zend_string * zs = zend_string_init (key , nr_strlen (key ), 0 );
110
65
111
66
retval = zend_hash_del (ht , zs );
112
67
zend_string_free (zs );
113
68
114
69
return (SUCCESS == retval );
115
- #else
116
- return (SUCCESS == zend_hash_del (ht , key , nr_strlen (key ) + 1 ));
117
- #endif /* PHP7 */
118
70
}
119
71
120
72
int nr_php_zend_hash_exists (const HashTable * ht , const char * key ) {
@@ -124,14 +76,9 @@ int nr_php_zend_hash_exists(const HashTable* ht, const char* key) {
124
76
* lookups!
125
77
*/
126
78
127
- #ifdef PHP7
128
79
return zend_hash_str_exists (ht , key , nr_strlen (key ));
129
- #else
130
- return zend_hash_exists (ht , key , nr_strlen (key ) + 1 );
131
- #endif /* PHP7 */
132
80
}
133
81
134
- #ifdef PHP7
135
82
zval * nr_php_zend_hash_find (const HashTable * ht , const char * key ) {
136
83
if ((NULL == ht ) || (NULL == key ) || ('\0' == key [0 ])) {
137
84
return NULL ;
@@ -155,49 +102,3 @@ zval* nr_php_zend_hash_index_find(const HashTable* ht, zend_ulong index) {
155
102
156
103
return zend_hash_index_find (ht , index );
157
104
}
158
- #else /* Not PHP7 */
159
- void * nr_php_zend_hash_find_ptr (const HashTable * ht , const char * key ) {
160
- void * data = NULL ;
161
- int keylen ;
162
- int rv ;
163
-
164
- if ((0 == ht ) || (0 == key )) {
165
- return NULL ;
166
- }
167
-
168
- keylen = nr_strlen (key );
169
- if (keylen <= 0 ) {
170
- return NULL ;
171
- }
172
- keylen += 1 ; /* Lookup length requires null terminator */
173
-
174
- rv = zend_hash_find (ht , key , keylen , & data );
175
- if (SUCCESS != rv ) {
176
- return NULL ;
177
- }
178
-
179
- return data ;
180
- }
181
-
182
- zval * nr_php_zend_hash_find (const HashTable * ht , const char * key ) {
183
- zval * * zv_pp = (zval * * )nr_php_zend_hash_find_ptr (ht , key );
184
-
185
- if (NULL == zv_pp ) {
186
- return NULL ;
187
- }
188
-
189
- return * zv_pp ;
190
- }
191
-
192
- zval * nr_php_zend_hash_index_find (const HashTable * ht , zend_ulong index ) {
193
- void * data = NULL ;
194
- int rv ;
195
-
196
- rv = zend_hash_index_find (ht , index , & data );
197
- if ((SUCCESS != rv ) || (NULL == data )) {
198
- return NULL ;
199
- }
200
-
201
- return * ((zval * * )data );
202
- }
203
- #endif /* PHP7 */
0 commit comments