php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_hash.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_HASH_H
22#define ZEND_HASH_H
23
24#include "zend_types.h"
25#include "zend_gc.h"
26#include "zend_string.h"
27#include "zend_sort.h"
28
29#define HASH_KEY_IS_STRING 1
30#define HASH_KEY_IS_LONG 2
31#define HASH_KEY_NON_EXISTENT 3
32
33#define HASH_UPDATE (1<<0)
34#define HASH_ADD (1<<1)
35#define HASH_UPDATE_INDIRECT (1<<2)
36#define HASH_ADD_NEW (1<<3)
37#define HASH_ADD_NEXT (1<<4)
38#define HASH_LOOKUP (1<<5)
39
40#define HASH_FLAG_CONSISTENCY ((1<<0) | (1<<1))
41#define HASH_FLAG_PACKED (1<<2)
42#define HASH_FLAG_UNINITIALIZED (1<<3)
43#define HASH_FLAG_STATIC_KEYS (1<<4) /* long and interned strings */
44#define HASH_FLAG_HAS_EMPTY_IND (1<<5)
45#define HASH_FLAG_ALLOW_COW_VIOLATION (1<<6)
46
47/* Only the low byte are real flags */
48#define HASH_FLAG_MASK 0xff
49
50#define HT_FLAGS(ht) (ht)->u.flags
51
52#define HT_INVALIDATE(ht) do { \
53 HT_FLAGS(ht) = HASH_FLAG_UNINITIALIZED; \
54 } while (0)
55
56#define HT_IS_INITIALIZED(ht) \
57 ((HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED) == 0)
58
59#define HT_IS_PACKED(ht) \
60 ((HT_FLAGS(ht) & HASH_FLAG_PACKED) != 0)
61
62#define HT_IS_WITHOUT_HOLES(ht) \
63 ((ht)->nNumUsed == (ht)->nNumOfElements)
64
65#define HT_HAS_STATIC_KEYS_ONLY(ht) \
66 ((HT_FLAGS(ht) & (HASH_FLAG_PACKED|HASH_FLAG_STATIC_KEYS)) != 0)
67
68#if ZEND_DEBUG
69# define HT_ALLOW_COW_VIOLATION(ht) HT_FLAGS(ht) |= HASH_FLAG_ALLOW_COW_VIOLATION
70#else
71# define HT_ALLOW_COW_VIOLATION(ht)
72#endif
73
74#define HT_ITERATORS_COUNT(ht) (ht)->u.v.nIteratorsCount
75#define HT_ITERATORS_OVERFLOW(ht) (HT_ITERATORS_COUNT(ht) == 0xff)
76#define HT_HAS_ITERATORS(ht) (HT_ITERATORS_COUNT(ht) != 0)
77
78#define HT_SET_ITERATORS_COUNT(ht, iters) \
79 do { HT_ITERATORS_COUNT(ht) = (iters); } while (0)
80#define HT_INC_ITERATORS_COUNT(ht) \
81 HT_SET_ITERATORS_COUNT(ht, HT_ITERATORS_COUNT(ht) + 1)
82#define HT_DEC_ITERATORS_COUNT(ht) \
83 HT_SET_ITERATORS_COUNT(ht, HT_ITERATORS_COUNT(ht) - 1)
84
86
87#define ZVAL_EMPTY_ARRAY(z) do { \
88 zval *__z = (z); \
89 Z_ARR_P(__z) = (zend_array*)&zend_empty_array; \
90 Z_TYPE_INFO_P(__z) = IS_ARRAY; \
91 } while (0)
92
93
98
99typedef bool (*merge_checker_func_t)(HashTable *target_ht, zval *source_data, zend_hash_key *hash_key, void *pParam);
100
102
103/* startup/shutdown */
104ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, bool persistent);
107
108#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
109 _zend_hash_init((ht), (nSize), (pDestructor), (persistent))
110
116ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed);
117ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed);
119
120/* additions/updates/changes */
126
127ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *key, size_t len, zval *pData, uint32_t flag);
128ZEND_API zval* ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *key, size_t len, zval *pData);
130ZEND_API zval* ZEND_FASTCALL zend_hash_str_add(HashTable *ht, const char *key, size_t len, zval *pData);
131ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *key, size_t len, zval *pData);
132
139
143
145
146#define ZEND_HASH_APPLY_KEEP 0
147#define ZEND_HASH_APPLY_REMOVE 1<<0
148#define ZEND_HASH_APPLY_STOP 1<<1
149
150typedef int (*apply_func_t)(zval *pDest);
151typedef int (*apply_func_arg_t)(zval *pDest, void *argument);
152typedef int (*apply_func_args_t)(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key);
153
159
160/* This function should be used with special care (in other words,
161 * it should usually not be used). When used with the ZEND_HASH_APPLY_STOP
162 * return value, it assumes things about the order of the elements in the hash.
163 * Also, it does not provide the same kind of reentrancy protection that
164 * the standard apply functions do.
165 */
167
168
169/* Deletes */
177
178/* Data retrieval */
180ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len);
183
184/* The same as zend_hash_find(), but hash value of the key must be already calculated. */
186
187static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash)
188{
189 if (known_hash) {
191 } else {
192 return zend_hash_find(ht, key);
193 }
194}
195
196#define ZEND_HASH_INDEX_FIND(_ht, _h, _ret, _not_found) do { \
197 if (EXPECTED(HT_IS_PACKED(_ht))) { \
198 if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) { \
199 _ret = &_ht->arPacked[_h]; \
200 if (UNEXPECTED(Z_TYPE_P(_ret) == IS_UNDEF)) { \
201 goto _not_found; \
202 } \
203 } else { \
204 goto _not_found; \
205 } \
206 } else { \
207 _ret = _zend_hash_index_find(_ht, _h); \
208 if (UNEXPECTED(_ret == NULL)) { \
209 goto _not_found; \
210 } \
211 } \
212 } while (0)
213
214
215/* Find or add NULL, if doesn't exist */
218
219#define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \
220 if (EXPECTED(HT_IS_PACKED(_ht))) { \
221 if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) { \
222 _ret = &_ht->arPacked[_h]; \
223 if (EXPECTED(Z_TYPE_P(_ret) != IS_UNDEF)) { \
224 break; \
225 } \
226 } \
227 } \
228 _ret = zend_hash_index_lookup(_ht, _h); \
229 } while (0)
230
231/* Misc */
232static zend_always_inline bool zend_hash_exists(const HashTable *ht, zend_string *key)
233{
234 return zend_hash_find(ht, key) != NULL;
235}
236
237static zend_always_inline bool zend_hash_str_exists(const HashTable *ht, const char *str, size_t len)
238{
239 return zend_hash_str_find(ht, str, len) != NULL;
240}
241
242static zend_always_inline bool zend_hash_index_exists(const HashTable *ht, zend_ulong h)
243{
244 return zend_hash_index_find(ht, h) != NULL;
245}
246
247/* traversing */
250
259
260static zend_always_inline zend_result zend_hash_has_more_elements_ex(HashTable *ht, HashPosition *pos) {
262}
263static zend_always_inline zend_result zend_hash_has_more_elements(HashTable *ht) {
264 return zend_hash_has_more_elements_ex(ht, &ht->nInternalPointer);
265}
266static zend_always_inline zend_result zend_hash_move_forward(HashTable *ht) {
267 return zend_hash_move_forward_ex(ht, &ht->nInternalPointer);
268}
269static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) {
270 return zend_hash_move_backwards_ex(ht, &ht->nInternalPointer);
271}
272static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) {
273 return zend_hash_get_current_key_ex(ht, str_index, num_index, &ht->nInternalPointer);
274}
275static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) {
276 zend_hash_get_current_key_zval_ex(ht, key, &ht->nInternalPointer);
277}
278static zend_always_inline int zend_hash_get_current_key_type(HashTable *ht) {
279 return zend_hash_get_current_key_type_ex(ht, &ht->nInternalPointer);
280}
281static zend_always_inline zval* zend_hash_get_current_data(HashTable *ht) {
282 return zend_hash_get_current_data_ex(ht, &ht->nInternalPointer);
283}
284static zend_always_inline void zend_hash_internal_pointer_reset(HashTable *ht) {
285 zend_hash_internal_pointer_reset_ex(ht, &ht->nInternalPointer);
286}
287static zend_always_inline void zend_hash_internal_pointer_end(HashTable *ht) {
288 zend_hash_internal_pointer_end_ex(ht, &ht->nInternalPointer);
289}
290
291/* Copying, merging and sorting */
292ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor);
293ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite);
294ZEND_API void ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam);
298
300ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered);
304
305static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) {
307}
308
309/* Use this variant over zend_hash_sort() when sorting user arrays that may
310 * trigger user code. It will ensure the user code cannot free the array during
311 * sorting. */
312static zend_always_inline void zend_array_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) {
314}
315
316static zend_always_inline uint32_t zend_hash_num_elements(const HashTable *ht) {
317 return ht->nNumOfElements;
318}
319
320static zend_always_inline zend_long zend_hash_next_free_element(const HashTable *ht) {
321 return ht->nNextFreeElement;
322}
323
325
326#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
327# define zend_new_array(size) \
328 (__builtin_constant_p(size) ? \
329 ((((uint32_t)(size)) <= HT_MIN_SIZE) ? \
330 _zend_new_array_0() \
331 : \
332 _zend_new_array((size)) \
333 ) \
334 : \
335 _zend_new_array((size)) \
336 )
337#else
338# define zend_new_array(size) \
339 _zend_new_array(size)
340#endif
341
352
353ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx);
354
362
363static zend_always_inline void zend_hash_iterators_update(HashTable *ht, HashPosition from, HashPosition to)
364{
367 }
368}
369
370/* For regular arrays (non-persistent, storing zvals). */
371static zend_always_inline void zend_array_release(zend_array *array)
372{
373 if (!(GC_FLAGS(array) & IS_ARRAY_IMMUTABLE)) {
374 if (GC_DELREF(array) == 0) {
375 zend_array_destroy(array);
376 }
377 }
378}
379
380/* For general hashes (possibly persistent, storing any kind of value). */
381static zend_always_inline void zend_hash_release(zend_array *array)
382{
383 if (!(GC_FLAGS(array) & IS_ARRAY_IMMUTABLE)) {
384 if (GC_DELREF(array) == 0) {
385 zend_hash_destroy(array);
386 pefree(array, GC_FLAGS(array) & IS_ARRAY_PERSISTENT);
387 }
388 }
389}
390
392
393#define ZEND_INIT_SYMTABLE(ht) \
394 ZEND_INIT_SYMTABLE_EX(ht, 8, 0)
395
396#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \
397 zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
398
399static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx)
400{
401 const char *tmp = key;
402
403 if (EXPECTED(*tmp > '9')) {
404 return 0;
405 } else if (*tmp < '0') {
406 if (*tmp != '-') {
407 return 0;
408 }
409 tmp++;
410 if (*tmp > '9' || *tmp < '0') {
411 return 0;
412 }
413 }
414 return _zend_handle_numeric_str_ex(key, length, idx);
415}
416
417#define ZEND_HANDLE_NUMERIC_STR(key, length, idx) \
418 _zend_handle_numeric_str(key, length, &idx)
419
420#define ZEND_HANDLE_NUMERIC(key, idx) \
421 ZEND_HANDLE_NUMERIC_STR(ZSTR_VAL(key), ZSTR_LEN(key), idx)
422
423
424static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key)
425{
426 zval *zv;
427
429 return (zv && Z_TYPE_P(zv) == IS_INDIRECT) ?
431}
432
433
434static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_string *key, bool known_hash)
435{
436 zval *zv;
437
438 zv = zend_hash_find_ex(ht, key, known_hash);
439 return (zv && Z_TYPE_P(zv) == IS_INDIRECT) ?
441}
442
443
444static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_string *key)
445{
446 zval *zv;
447
449 return zv && (Z_TYPE_P(zv) != IS_INDIRECT ||
451}
452
453
454static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, size_t len)
455{
456 zval *zv;
457
458 zv = zend_hash_str_find(ht, str, len);
459 return (zv && Z_TYPE_P(zv) == IS_INDIRECT) ?
461}
462
463
464static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len)
465{
466 zval *zv;
467
468 zv = zend_hash_str_find(ht, str, len);
469 return zv && (Z_TYPE_P(zv) != IS_INDIRECT ||
471}
472
473static zend_always_inline zval *zend_symtable_add_new(HashTable *ht, zend_string *key, zval *pData)
474{
475 zend_ulong idx;
476
477 if (ZEND_HANDLE_NUMERIC(key, idx)) {
478 return zend_hash_index_add_new(ht, idx, pData);
479 } else {
480 return zend_hash_add_new(ht, key, pData);
481 }
482}
483
484static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
485{
486 zend_ulong idx;
487
488 if (ZEND_HANDLE_NUMERIC(key, idx)) {
489 return zend_hash_index_update(ht, idx, pData);
490 } else {
491 return zend_hash_update(ht, key, pData);
492 }
493}
494
495
496static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData)
497{
498 zend_ulong idx;
499
500 if (ZEND_HANDLE_NUMERIC(key, idx)) {
501 return zend_hash_index_update(ht, idx, pData);
502 } else {
503 return zend_hash_update_ind(ht, key, pData);
504 }
505}
506
507
508static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_string *key)
509{
510 zend_ulong idx;
511
512 if (ZEND_HANDLE_NUMERIC(key, idx)) {
513 return zend_hash_index_del(ht, idx);
514 } else {
515 return zend_hash_del(ht, key);
516 }
517}
518
519
520static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_string *key)
521{
522 zend_ulong idx;
523
524 if (ZEND_HANDLE_NUMERIC(key, idx)) {
525 return zend_hash_index_del(ht, idx);
526 } else {
527 return zend_hash_del_ind(ht, key);
528 }
529}
530
531
532static zend_always_inline zval *zend_symtable_find(const HashTable *ht, zend_string *key)
533{
534 zend_ulong idx;
535
536 if (ZEND_HANDLE_NUMERIC(key, idx)) {
537 return zend_hash_index_find(ht, idx);
538 } else {
539 return zend_hash_find(ht, key);
540 }
541}
542
543
544static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key)
545{
546 zend_ulong idx;
547
548 if (ZEND_HANDLE_NUMERIC(key, idx)) {
549 return zend_hash_index_find(ht, idx);
550 } else {
551 return zend_hash_find_ind(ht, key);
552 }
553}
554
555
556static zend_always_inline bool zend_symtable_exists(HashTable *ht, zend_string *key)
557{
558 zend_ulong idx;
559
560 if (ZEND_HANDLE_NUMERIC(key, idx)) {
561 return zend_hash_index_exists(ht, idx);
562 } else {
563 return zend_hash_exists(ht, key);
564 }
565}
566
567
568static zend_always_inline bool zend_symtable_exists_ind(HashTable *ht, zend_string *key)
569{
570 zend_ulong idx;
571
572 if (ZEND_HANDLE_NUMERIC(key, idx)) {
573 return zend_hash_index_exists(ht, idx);
574 } else {
575 return zend_hash_exists_ind(ht, key);
576 }
577}
578
579
580static zend_always_inline zval *zend_symtable_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
581{
582 zend_ulong idx;
583
584 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
585 return zend_hash_index_update(ht, idx, pData);
586 } else {
587 return zend_hash_str_update(ht, str, len, pData);
588 }
589}
590
591
592static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData)
593{
594 zend_ulong idx;
595
596 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
597 return zend_hash_index_update(ht, idx, pData);
598 } else {
599 return zend_hash_str_update_ind(ht, str, len, pData);
600 }
601}
602
603
604static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const char *str, size_t len)
605{
606 zend_ulong idx;
607
608 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
609 return zend_hash_index_del(ht, idx);
610 } else {
611 return zend_hash_str_del(ht, str, len);
612 }
613}
614
615
616static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len)
617{
618 zend_ulong idx;
619
620 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
621 return zend_hash_index_del(ht, idx);
622 } else {
623 return zend_hash_str_del_ind(ht, str, len);
624 }
625}
626
627
628static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char *str, size_t len)
629{
630 zend_ulong idx;
631
632 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
633 return zend_hash_index_find(ht, idx);
634 } else {
635 return zend_hash_str_find(ht, str, len);
636 }
637}
638
639
640static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const char *str, size_t len)
641{
642 zend_ulong idx;
643
644 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
645 return zend_hash_index_exists(ht, idx);
646 } else {
647 return zend_hash_str_exists(ht, str, len);
648 }
649}
650
651static zend_always_inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData)
652{
653 zval tmp, *zv;
654
655 ZVAL_PTR(&tmp, pData);
656 zv = zend_hash_add(ht, key, &tmp);
657 if (zv) {
659 return Z_PTR_P(zv);
660 } else {
661 return NULL;
662 }
663}
664
665static zend_always_inline void *zend_hash_add_new_ptr(HashTable *ht, zend_string *key, void *pData)
666{
667 zval tmp, *zv;
668
669 ZVAL_PTR(&tmp, pData);
670 zv = zend_hash_add_new(ht, key, &tmp);
671 if (zv) {
673 return Z_PTR_P(zv);
674 } else {
675 return NULL;
676 }
677}
678
679static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData)
680{
681 zval tmp, *zv;
682
683 ZVAL_PTR(&tmp, pData);
684 zv = zend_hash_str_add(ht, str, len, &tmp);
685 if (zv) {
687 return Z_PTR_P(zv);
688 } else {
689 return NULL;
690 }
691}
692
693static zend_always_inline void *zend_hash_str_add_new_ptr(HashTable *ht, const char *str, size_t len, void *pData)
694{
695 zval tmp, *zv;
696
697 ZVAL_PTR(&tmp, pData);
698 zv = zend_hash_str_add_new(ht, str, len, &tmp);
699 if (zv) {
701 return Z_PTR_P(zv);
702 } else {
703 return NULL;
704 }
705}
706
707static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string *key, void *pData)
708{
709 zval tmp, *zv;
710
711 ZVAL_PTR(&tmp, pData);
712 zv = zend_hash_update(ht, key, &tmp);
714 return Z_PTR_P(zv);
715}
716
717static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const char *str, size_t len, void *pData)
718{
719 zval tmp, *zv;
720
721 ZVAL_PTR(&tmp, pData);
722 zv = zend_hash_str_update(ht, str, len, &tmp);
724 return Z_PTR_P(zv);
725}
726
727static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pData, size_t size)
728{
729 zval tmp, *zv;
730
731 ZVAL_PTR(&tmp, NULL);
732 if ((zv = zend_hash_add(ht, key, &tmp))) {
734 memcpy(Z_PTR_P(zv), pData, size);
735 return Z_PTR_P(zv);
736 }
737 return NULL;
738}
739
740static zend_always_inline void *zend_hash_add_new_mem(HashTable *ht, zend_string *key, void *pData, size_t size)
741{
742 zval tmp, *zv;
743
744 ZVAL_PTR(&tmp, NULL);
745 if ((zv = zend_hash_add_new(ht, key, &tmp))) {
747 memcpy(Z_PTR_P(zv), pData, size);
748 return Z_PTR_P(zv);
749 }
750 return NULL;
751}
752
753static zend_always_inline void *zend_hash_str_add_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size)
754{
755 zval tmp, *zv;
756
757 ZVAL_PTR(&tmp, NULL);
758 if ((zv = zend_hash_str_add(ht, str, len, &tmp))) {
760 memcpy(Z_PTR_P(zv), pData, size);
761 return Z_PTR_P(zv);
762 }
763 return NULL;
764}
765
766static zend_always_inline void *zend_hash_str_add_new_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size)
767{
768 zval tmp, *zv;
769
770 ZVAL_PTR(&tmp, NULL);
771 if ((zv = zend_hash_str_add_new(ht, str, len, &tmp))) {
773 memcpy(Z_PTR_P(zv), pData, size);
774 return Z_PTR_P(zv);
775 }
776 return NULL;
777}
778
779static zend_always_inline void *zend_hash_update_mem(HashTable *ht, zend_string *key, void *pData, size_t size)
780{
781 void *p;
782
784 memcpy(p, pData, size);
785 return zend_hash_update_ptr(ht, key, p);
786}
787
788static zend_always_inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size)
789{
790 void *p;
791
793 memcpy(p, pData, size);
794 return zend_hash_str_update_ptr(ht, str, len, p);
795}
796
797static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData)
798{
799 zval tmp, *zv;
800
801 ZVAL_PTR(&tmp, pData);
802 zv = zend_hash_index_add(ht, h, &tmp);
803 return zv ? Z_PTR_P(zv) : NULL;
804}
805
806static zend_always_inline void *zend_hash_index_add_new_ptr(HashTable *ht, zend_ulong h, void *pData)
807{
808 zval tmp, *zv;
809
810 ZVAL_PTR(&tmp, pData);
811 zv = zend_hash_index_add_new(ht, h, &tmp);
812 return zv ? Z_PTR_P(zv) : NULL;
813}
814
815static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void *pData)
816{
817 zval tmp, *zv;
818
819 ZVAL_PTR(&tmp, pData);
820 zv = zend_hash_index_update(ht, h, &tmp);
822 return Z_PTR_P(zv);
823}
824
825static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
826{
827 zval tmp, *zv;
828
829 ZVAL_PTR(&tmp, NULL);
830 if ((zv = zend_hash_index_add(ht, h, &tmp))) {
832 memcpy(Z_PTR_P(zv), pData, size);
833 return Z_PTR_P(zv);
834 }
835 return NULL;
836}
837
838static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData)
839{
840 zval tmp, *zv;
841
842 ZVAL_PTR(&tmp, pData);
844 if (zv) {
846 return Z_PTR_P(zv);
847 } else {
848 return NULL;
849 }
850}
851
852static zend_always_inline void *zend_hash_index_update_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
853{
854 void *p;
855
857 memcpy(p, pData, size);
858 return zend_hash_index_update_ptr(ht, h, p);
859}
860
861static zend_always_inline void *zend_hash_next_index_insert_mem(HashTable *ht, void *pData, size_t size)
862{
863 zval tmp;
864
866 memcpy(p, pData, size);
867 ZVAL_PTR(&tmp, p);
868 if (!zend_hash_next_index_insert(ht, &tmp)) {
870 return NULL;
871 }
872 return p;
873}
874
875static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_string *key)
876{
877 zval *zv;
878
880 if (zv) {
882 return Z_PTR_P(zv);
883 } else {
884 return NULL;
885 }
886}
887
888static zend_always_inline void *zend_hash_find_ex_ptr(const HashTable *ht, zend_string *key, bool known_hash)
889{
890 zval *zv;
891
892 zv = zend_hash_find_ex(ht, key, known_hash);
893 if (zv) {
895 return Z_PTR_P(zv);
896 } else {
897 return NULL;
898 }
899}
900
901static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len)
902{
903 zval *zv;
904
905 zv = zend_hash_str_find(ht, str, len);
906 if (zv) {
908 return Z_PTR_P(zv);
909 } else {
910 return NULL;
911 }
912}
913
915
916/* Will lowercase the str; use only if you don't need the lowercased string for
917 * anything else. If you have a lowered string, use zend_hash_str_find_ptr. */
918ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len);
919
920/* Will lowercase the str; use only if you don't need the lowercased string for
921 * anything else. If you have a lowered string, use zend_hash_find_ptr. */
923
925
926static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_ulong h)
927{
928 zval *zv;
929
931 if (zv) {
933 return Z_PTR_P(zv);
934 } else {
935 return NULL;
936 }
937}
938
939static zend_always_inline zval *zend_hash_index_find_deref(HashTable *ht, zend_ulong h)
940{
942 if (zv) {
943 ZVAL_DEREF(zv);
944 }
945 return zv;
946}
947
948static zend_always_inline zval *zend_hash_find_deref(HashTable *ht, zend_string *str)
949{
950 zval *zv = zend_hash_find(ht, str);
951 if (zv) {
952 ZVAL_DEREF(zv);
953 }
954 return zv;
955}
956
957static zend_always_inline zval *zend_hash_str_find_deref(HashTable *ht, const char *str, size_t len)
958{
959 zval *zv = zend_hash_str_find(ht, str, len);
960 if (zv) {
961 ZVAL_DEREF(zv);
962 }
963 return zv;
964}
965
966static zend_always_inline void *zend_symtable_str_find_ptr(HashTable *ht, const char *str, size_t len)
967{
968 zend_ulong idx;
969
970 if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
971 return zend_hash_index_find_ptr(ht, idx);
972 } else {
973 return zend_hash_str_find_ptr(ht, str, len);
974 }
975}
976
977static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, HashPosition *pos)
978{
979 zval *zv;
980
982 if (zv) {
984 return Z_PTR_P(zv);
985 } else {
986 return NULL;
987 }
988}
989
990#define zend_hash_get_current_data_ptr(ht) \
991 zend_hash_get_current_data_ptr_ex(ht, &(ht)->nInternalPointer)
992
993/* Common hash/packed array iterators */
994#if 0
995# define ZEND_HASH_ELEMENT_SIZE(__ht) \
996 (HT_IS_PACKED(__ht) ? sizeof(zval) : sizeof(Bucket))
997#else /* optimized version */
998# define ZEND_HASH_ELEMENT_SIZE(__ht) \
999 (sizeof(zval) + (~HT_FLAGS(__ht) & HASH_FLAG_PACKED) * ((sizeof(Bucket)-sizeof(zval))/HASH_FLAG_PACKED))
1000#endif
1001
1002#define ZEND_HASH_ELEMENT_EX(__ht, _idx, _size) \
1003 ((zval*)(((char*)(__ht)->arPacked) + ((_idx) * (_size))))
1004
1005#define ZEND_HASH_ELEMENT(__ht, _idx) \
1006 ZEND_HASH_ELEMENT_EX(__ht, _idx, ZEND_HASH_ELEMENT_SIZE(__ht))
1007
1008#define ZEND_HASH_NEXT_ELEMENT(_el, _size) \
1009 ((zval*)(((char*)(_el)) + (_size)))
1010
1011#define ZEND_HASH_PREV_ELEMENT(_el, _size) \
1012 ((zval*)(((char*)(_el)) - (_size)))
1013
1014#define _ZEND_HASH_FOREACH_VAL(_ht) do { \
1015 const HashTable *__ht = (_ht); \
1016 uint32_t _count = __ht->nNumUsed; \
1017 size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \
1018 zval *_z = __ht->arPacked; \
1019 for (; _count > 0; _z = ZEND_HASH_NEXT_ELEMENT(_z, _size), _count--) { \
1020 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1021
1022#define _ZEND_HASH_REVERSE_FOREACH_VAL(_ht) do { \
1023 const HashTable *__ht = (_ht); \
1024 uint32_t _idx = __ht->nNumUsed; \
1025 size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \
1026 zval *_z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \
1027 for (;_idx > 0; _idx--) { \
1028 _z = ZEND_HASH_PREV_ELEMENT(_z, _size); \
1029 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1030
1031#define ZEND_HASH_FOREACH_FROM(_ht, indirect, _from) do { \
1032 const HashTable *__ht = (_ht); \
1033 zend_ulong __h; \
1034 zend_string *__key = NULL; \
1035 uint32_t _idx = (_from); \
1036 size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \
1037 zval *__z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \
1038 uint32_t _count = __ht->nNumUsed - _idx; \
1039 for (;_count > 0; _count--) { \
1040 zval *_z = __z; \
1041 if (HT_IS_PACKED(__ht)) { \
1042 __z++; \
1043 __h = _idx; \
1044 _idx++; \
1045 } else { \
1046 Bucket *_p = (Bucket*)__z; \
1047 __z = &(_p + 1)->val; \
1048 __h = _p->h; \
1049 __key = _p->key; \
1050 if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
1051 _z = Z_INDIRECT_P(_z); \
1052 } \
1053 } \
1054 (void) __h; (void) __key; (void) _idx; \
1055 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1056
1057#define ZEND_HASH_FOREACH(_ht, indirect) ZEND_HASH_FOREACH_FROM(_ht, indirect, 0)
1058
1059#define ZEND_HASH_REVERSE_FOREACH(_ht, indirect) do { \
1060 const HashTable *__ht = (_ht); \
1061 uint32_t _idx = __ht->nNumUsed; \
1062 zval *_z; \
1063 zend_ulong __h; \
1064 zend_string *__key = NULL; \
1065 size_t _size = ZEND_HASH_ELEMENT_SIZE(__ht); \
1066 zval *__z = ZEND_HASH_ELEMENT_EX(__ht, _idx, _size); \
1067 for (;_idx > 0; _idx--) { \
1068 if (HT_IS_PACKED(__ht)) { \
1069 __z--; \
1070 _z = __z; \
1071 __h = _idx - 1; \
1072 } else { \
1073 Bucket *_p = (Bucket*)__z; \
1074 _p--; \
1075 __z = &_p->val; \
1076 _z = __z; \
1077 __h = _p->h; \
1078 __key = _p->key; \
1079 if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
1080 _z = Z_INDIRECT_P(_z); \
1081 } \
1082 } \
1083 (void) __h; (void) __key; (void) __z; \
1084 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1085
1086#define ZEND_HASH_FOREACH_END() \
1087 } \
1088 } while (0)
1089
1090#define ZEND_HASH_FOREACH_END_DEL() \
1091 ZEND_HASH_MAP_FOREACH_END_DEL()
1092
1093#define ZEND_HASH_FOREACH_BUCKET(ht, _bucket) \
1094 ZEND_HASH_MAP_FOREACH_BUCKET(ht, _bucket)
1095
1096#define ZEND_HASH_FOREACH_BUCKET_FROM(ht, _bucket, _from) \
1097 ZEND_HASH_MAP_FOREACH_BUCKET_FROM(ht, _bucket, _from)
1098
1099#define ZEND_HASH_REVERSE_FOREACH_BUCKET(ht, _bucket) \
1100 ZEND_HASH_MAP_REVERSE_FOREACH_BUCKET(ht, _bucket)
1101
1102#define ZEND_HASH_FOREACH_VAL(ht, _val) \
1103 _ZEND_HASH_FOREACH_VAL(ht); \
1104 _val = _z;
1105
1106#define ZEND_HASH_REVERSE_FOREACH_VAL(ht, _val) \
1107 _ZEND_HASH_REVERSE_FOREACH_VAL(ht); \
1108 _val = _z;
1109
1110#define ZEND_HASH_FOREACH_VAL_IND(ht, _val) \
1111 ZEND_HASH_FOREACH(ht, 1); \
1112 _val = _z;
1113
1114#define ZEND_HASH_REVERSE_FOREACH_VAL_IND(ht, _val) \
1115 ZEND_HASH_REVERSE_FOREACH(ht, 1); \
1116 _val = _z;
1117
1118#define ZEND_HASH_FOREACH_PTR(ht, _ptr) \
1119 _ZEND_HASH_FOREACH_VAL(ht); \
1120 _ptr = Z_PTR_P(_z);
1121
1122#define ZEND_HASH_FOREACH_PTR_FROM(ht, _ptr, _from) \
1123 ZEND_HASH_FOREACH_FROM(ht, 0, _from); \
1124 _ptr = Z_PTR_P(_z);
1125
1126#define ZEND_HASH_REVERSE_FOREACH_PTR(ht, _ptr) \
1127 _ZEND_HASH_REVERSE_FOREACH_VAL(ht); \
1128 _ptr = Z_PTR_P(_z);
1129
1130#define ZEND_HASH_FOREACH_NUM_KEY(ht, _h) \
1131 ZEND_HASH_FOREACH(ht, 0); \
1132 _h = __h;
1133
1134#define ZEND_HASH_REVERSE_FOREACH_NUM_KEY(ht, _h) \
1135 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1136 _h = __h;
1137
1138#define ZEND_HASH_FOREACH_STR_KEY(ht, _key) \
1139 ZEND_HASH_FOREACH(ht, 0); \
1140 _key = __key;
1141
1142#define ZEND_HASH_REVERSE_FOREACH_STR_KEY(ht, _key) \
1143 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1144 _key = __key;
1145
1146#define ZEND_HASH_FOREACH_KEY(ht, _h, _key) \
1147 ZEND_HASH_FOREACH(ht, 0); \
1148 _h = __h; \
1149 _key = __key;
1150
1151#define ZEND_HASH_REVERSE_FOREACH_KEY(ht, _h, _key) \
1152 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1153 _h = __h; \
1154 _key = __key;
1155
1156#define ZEND_HASH_FOREACH_NUM_KEY_VAL(ht, _h, _val) \
1157 ZEND_HASH_FOREACH(ht, 0); \
1158 _h = __h; \
1159 _val = _z;
1160
1161#define ZEND_HASH_REVERSE_FOREACH_NUM_KEY_VAL(ht, _h, _val) \
1162 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1163 _h = __h; \
1164 _val = _z;
1165
1166#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
1167 ZEND_HASH_FOREACH(ht, 0); \
1168 _key = __key; \
1169 _val = _z;
1170
1171#define ZEND_HASH_FOREACH_STR_KEY_VAL_FROM(ht, _key, _val, _from) \
1172 ZEND_HASH_FOREACH_FROM(ht, 0, _from); \
1173 _key = __key; \
1174 _val = _z;
1175
1176#define ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL(ht, _key, _val) \
1177 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1178 _key = __key; \
1179 _val = _z;
1180
1181#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val) \
1182 ZEND_HASH_FOREACH(ht, 0); \
1183 _h = __h; \
1184 _key = __key; \
1185 _val = _z;
1186
1187#define ZEND_HASH_REVERSE_FOREACH_KEY_VAL(ht, _h, _key, _val) \
1188 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1189 _h = __h; \
1190 _key = __key; \
1191 _val = _z;
1192
1193#define ZEND_HASH_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
1194 ZEND_HASH_FOREACH(ht, 1); \
1195 _key = __key; \
1196 _val = _z;
1197
1198#define ZEND_HASH_REVERSE_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
1199 ZEND_HASH_REVERSE_FOREACH(ht, 1); \
1200 _key = __key; \
1201 _val = _z;
1202
1203#define ZEND_HASH_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
1204 ZEND_HASH_FOREACH(ht, 1); \
1205 _h = __h; \
1206 _key = __key; \
1207 _val = _z;
1208
1209#define ZEND_HASH_REVERSE_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
1210 ZEND_HASH_REVERSE_FOREACH(ht, 1); \
1211 _h = __h; \
1212 _key = __key; \
1213 _val = _z;
1214
1215#define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
1216 ZEND_HASH_FOREACH(ht, 0); \
1217 _h = __h; \
1218 _ptr = Z_PTR_P(_z);
1219
1220#define ZEND_HASH_REVERSE_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
1221 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1222 _h = __h; \
1223 _ptr = Z_PTR_P(_z);
1224
1225#define ZEND_HASH_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
1226 ZEND_HASH_FOREACH(ht, 0); \
1227 _key = __key; \
1228 _ptr = Z_PTR_P(_z);
1229
1230#define ZEND_HASH_REVERSE_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
1231 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1232 _key = __key; \
1233 _ptr = Z_PTR_P(_z);
1234
1235#define ZEND_HASH_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
1236 ZEND_HASH_FOREACH(ht, 0); \
1237 _h = __h; \
1238 _key = __key; \
1239 _ptr = Z_PTR_P(_z);
1240
1241#define ZEND_HASH_REVERSE_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
1242 ZEND_HASH_REVERSE_FOREACH(ht, 0); \
1243 _h = __h; \
1244 _key = __key; \
1245 _ptr = Z_PTR_P(_z);
1246
1247/* Hash array iterators */
1248#define ZEND_HASH_MAP_FOREACH_FROM(_ht, indirect, _from) do { \
1249 const HashTable *__ht = (_ht); \
1250 Bucket *_p = __ht->arData + (_from); \
1251 const Bucket *_end = __ht->arData + __ht->nNumUsed; \
1252 ZEND_ASSERT(!HT_IS_PACKED(__ht)); \
1253 for (; _p != _end; _p++) { \
1254 zval *_z = &_p->val; \
1255 if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
1256 _z = Z_INDIRECT_P(_z); \
1257 } \
1258 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1259
1260#define ZEND_HASH_MAP_FOREACH(_ht, indirect) ZEND_HASH_MAP_FOREACH_FROM(_ht, indirect, 0)
1261
1262#define ZEND_HASH_MAP_REVERSE_FOREACH(_ht, indirect) do { \
1263 /* const */ HashTable *__ht = (_ht); \
1264 uint32_t _idx = __ht->nNumUsed; \
1265 Bucket *_p = __ht->arData + _idx; \
1266 zval *_z; \
1267 ZEND_ASSERT(!HT_IS_PACKED(__ht)); \
1268 for (_idx = __ht->nNumUsed; _idx > 0; _idx--) { \
1269 _p--; \
1270 _z = &_p->val; \
1271 if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \
1272 _z = Z_INDIRECT_P(_z); \
1273 } \
1274 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1275
1276#define ZEND_HASH_MAP_FOREACH_END_DEL() \
1277 ZEND_ASSERT(!HT_IS_PACKED(__ht)); \
1278 __ht->nNumOfElements--; \
1279 do { \
1280 uint32_t j = HT_IDX_TO_HASH(_idx - 1); \
1281 uint32_t nIndex = _p->h | __ht->nTableMask; \
1282 uint32_t i = HT_HASH(__ht, nIndex); \
1283 if (UNEXPECTED(j != i)) { \
1284 Bucket *prev = HT_HASH_TO_BUCKET(__ht, i); \
1285 while (Z_NEXT(prev->val) != j) { \
1286 i = Z_NEXT(prev->val); \
1287 prev = HT_HASH_TO_BUCKET(__ht, i); \
1288 } \
1289 Z_NEXT(prev->val) = Z_NEXT(_p->val); \
1290 } else { \
1291 HT_HASH(__ht, nIndex) = Z_NEXT(_p->val); \
1292 } \
1293 } while (0); \
1294 } \
1295 __ht->nNumUsed = _idx; \
1296 } while (0)
1297
1298#define ZEND_HASH_MAP_FOREACH_BUCKET(ht, _bucket) \
1299 ZEND_HASH_MAP_FOREACH(ht, 0); \
1300 _bucket = _p;
1301
1302#define ZEND_HASH_MAP_FOREACH_BUCKET_FROM(ht, _bucket, _from) \
1303 ZEND_HASH_MAP_FOREACH_FROM(ht, 0, _from); \
1304 _bucket = _p;
1305
1306#define ZEND_HASH_MAP_REVERSE_FOREACH_BUCKET(ht, _bucket) \
1307 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1308 _bucket = _p;
1309
1310#define ZEND_HASH_MAP_FOREACH_VAL(ht, _val) \
1311 ZEND_HASH_MAP_FOREACH(ht, 0); \
1312 _val = _z;
1313
1314#define ZEND_HASH_MAP_REVERSE_FOREACH_VAL(ht, _val) \
1315 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1316 _val = _z;
1317
1318#define ZEND_HASH_MAP_FOREACH_VAL_IND(ht, _val) \
1319 ZEND_HASH_MAP_FOREACH(ht, 1); \
1320 _val = _z;
1321
1322#define ZEND_HASH_MAP_REVERSE_FOREACH_VAL_IND(ht, _val) \
1323 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 1); \
1324 _val = _z;
1325
1326#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr) \
1327 ZEND_HASH_MAP_FOREACH(ht, 0); \
1328 _ptr = Z_PTR_P(_z);
1329
1330#define ZEND_HASH_MAP_FOREACH_PTR_FROM(ht, _ptr, _from) \
1331 ZEND_HASH_MAP_FOREACH_FROM(ht, 0, _from); \
1332 _ptr = Z_PTR_P(_z);
1333
1334#define ZEND_HASH_MAP_REVERSE_FOREACH_PTR(ht, _ptr) \
1335 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1336 _ptr = Z_PTR_P(_z);
1337
1338#define ZEND_HASH_MAP_FOREACH_NUM_KEY(ht, _h) \
1339 ZEND_HASH_MAP_FOREACH(ht, 0); \
1340 _h = _p->h;
1341
1342#define ZEND_HASH_MAP_REVERSE_FOREACH_NUM_KEY(ht, _h) \
1343 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1344 _h = _p->h;
1345
1346#define ZEND_HASH_MAP_FOREACH_STR_KEY(ht, _key) \
1347 ZEND_HASH_MAP_FOREACH(ht, 0); \
1348 _key = _p->key;
1349
1350#define ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY(ht, _key) \
1351 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1352 _key = _p->key;
1353
1354#define ZEND_HASH_MAP_FOREACH_KEY(ht, _h, _key) \
1355 ZEND_HASH_MAP_FOREACH(ht, 0); \
1356 _h = _p->h; \
1357 _key = _p->key;
1358
1359#define ZEND_HASH_MAP_REVERSE_FOREACH_KEY(ht, _h, _key) \
1360 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1361 _h = _p->h; \
1362 _key = _p->key;
1363
1364#define ZEND_HASH_MAP_FOREACH_NUM_KEY_VAL(ht, _h, _val) \
1365 ZEND_HASH_MAP_FOREACH(ht, 0); \
1366 _h = _p->h; \
1367 _val = _z;
1368
1369#define ZEND_HASH_MAP_REVERSE_FOREACH_NUM_KEY_VAL(ht, _h, _val) \
1370 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1371 _h = _p->h; \
1372 _val = _z;
1373
1374#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(ht, _key, _val) \
1375 ZEND_HASH_MAP_FOREACH(ht, 0); \
1376 _key = _p->key; \
1377 _val = _z;
1378
1379#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_FROM(ht, _key, _val, _from) \
1380 ZEND_HASH_MAP_FOREACH_FROM(ht, 0, _from); \
1381 _key = _p->key; \
1382 _val = _z;
1383
1384#define ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(ht, _key, _val) \
1385 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1386 _key = _p->key; \
1387 _val = _z;
1388
1389#define ZEND_HASH_MAP_FOREACH_KEY_VAL(ht, _h, _key, _val) \
1390 ZEND_HASH_MAP_FOREACH(ht, 0); \
1391 _h = _p->h; \
1392 _key = _p->key; \
1393 _val = _z;
1394
1395#define ZEND_HASH_MAP_REVERSE_FOREACH_KEY_VAL(ht, _h, _key, _val) \
1396 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1397 _h = _p->h; \
1398 _key = _p->key; \
1399 _val = _z;
1400
1401#define ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
1402 ZEND_HASH_MAP_FOREACH(ht, 1); \
1403 _key = _p->key; \
1404 _val = _z;
1405
1406#define ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL_IND(ht, _key, _val) \
1407 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 1); \
1408 _key = _p->key; \
1409 _val = _z;
1410
1411#define ZEND_HASH_MAP_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
1412 ZEND_HASH_MAP_FOREACH(ht, 1); \
1413 _h = _p->h; \
1414 _key = _p->key; \
1415 _val = _z;
1416
1417#define ZEND_HASH_MAP_REVERSE_FOREACH_KEY_VAL_IND(ht, _h, _key, _val) \
1418 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 1); \
1419 _h = _p->h; \
1420 _key = _p->key; \
1421 _val = _z;
1422
1423#define ZEND_HASH_MAP_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
1424 ZEND_HASH_MAP_FOREACH(ht, 0); \
1425 _h = _p->h; \
1426 _ptr = Z_PTR_P(_z);
1427
1428#define ZEND_HASH_MAP_REVERSE_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
1429 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1430 _h = _p->h; \
1431 _ptr = Z_PTR_P(_z);
1432
1433#define ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
1434 ZEND_HASH_MAP_FOREACH(ht, 0); \
1435 _key = _p->key; \
1436 _ptr = Z_PTR_P(_z);
1437
1438#define ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_PTR(ht, _key, _ptr) \
1439 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1440 _key = _p->key; \
1441 _ptr = Z_PTR_P(_z);
1442
1443#define ZEND_HASH_MAP_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
1444 ZEND_HASH_MAP_FOREACH(ht, 0); \
1445 _h = _p->h; \
1446 _key = _p->key; \
1447 _ptr = Z_PTR_P(_z);
1448
1449#define ZEND_HASH_MAP_REVERSE_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \
1450 ZEND_HASH_MAP_REVERSE_FOREACH(ht, 0); \
1451 _h = _p->h; \
1452 _key = _p->key; \
1453 _ptr = Z_PTR_P(_z);
1454
1455/* Packed array iterators */
1456#define ZEND_HASH_PACKED_FOREACH_FROM(_ht, _from) do { \
1457 const HashTable *__ht = (_ht); \
1458 zend_ulong _idx = (_from); \
1459 zval *_z = __ht->arPacked + (_from); \
1460 zval *_end = __ht->arPacked + __ht->nNumUsed; \
1461 ZEND_ASSERT(HT_IS_PACKED(__ht)); \
1462 for (;_z != _end; _z++, _idx++) { \
1463 (void) _idx; \
1464 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1465
1466#define ZEND_HASH_PACKED_FOREACH(_ht) ZEND_HASH_PACKED_FOREACH_FROM(_ht, 0)
1467
1468#define ZEND_HASH_PACKED_REVERSE_FOREACH(_ht) do { \
1469 const HashTable *__ht = (_ht); \
1470 zend_ulong _idx = __ht->nNumUsed; \
1471 zval *_z = __ht->arPacked + _idx; \
1472 ZEND_ASSERT(HT_IS_PACKED(__ht)); \
1473 while (_idx > 0) { \
1474 _z--; \
1475 _idx--; \
1476 (void) _idx; \
1477 if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue;
1478
1479#define ZEND_HASH_PACKED_FOREACH_VAL(ht, _val) \
1480 ZEND_HASH_PACKED_FOREACH(ht); \
1481 _val = _z;
1482
1483#define ZEND_HASH_PACKED_REVERSE_FOREACH_VAL(ht, _val) \
1484 ZEND_HASH_PACKED_REVERSE_FOREACH(ht); \
1485 _val = _z;
1486
1487#define ZEND_HASH_PACKED_FOREACH_PTR(ht, _ptr) \
1488 ZEND_HASH_PACKED_FOREACH(ht); \
1489 _ptr = Z_PTR_P(_z);
1490
1491#define ZEND_HASH_PACKED_REVERSE_FOREACH_PTR(ht, _ptr) \
1492 ZEND_HASH_PACKED_REVERSE_FOREACH(ht); \
1493 _ptr = Z_PTR_P(_z);
1494
1495#define ZEND_HASH_PACKED_FOREACH_KEY(ht, _h) \
1496 ZEND_HASH_PACKED_FOREACH(ht); \
1497 _h = _idx;
1498
1499#define ZEND_HASH_PACKED_REVERSE_FOREACH_KEY(ht, _h) \
1500 ZEND_HASH_PACKED_REVERSE_FOREACH(ht); \
1501 _h = _idx;
1502
1503#define ZEND_HASH_PACKED_FOREACH_KEY_VAL(ht, _h, _val) \
1504 ZEND_HASH_PACKED_FOREACH(ht); \
1505 _h = _idx; \
1506 _val = _z;
1507
1508#define ZEND_HASH_PACKED_REVERSE_FOREACH_KEY_VAL(ht, _h, _val) \
1509 ZEND_HASH_PACKED_REVERSE_FOREACH(ht); \
1510 _h = _idx; \
1511 _val = _z;
1512
1513#define ZEND_HASH_PACKED_FOREACH_KEY_PTR(ht, _h, _ptr) \
1514 ZEND_HASH_PACKED_FOREACH(ht); \
1515 _h = _idx; \
1516 _ptr = Z_PTR_P(_z);
1517
1518#define ZEND_HASH_PACKED_REVERSE_FOREACH_KEY_PTR(ht, _h, _ptr) \
1519 ZEND_HASH_PACKED_REVERSE_FOREACH(ht); \
1520 _h = _idx; \
1521 _ptr = Z_PTR_P(_z);
1522
1523/* The following macros are useful to insert a sequence of new elements
1524 * of packed array. They may be used instead of series of
1525 * zend_hash_next_index_insert_new()
1526 * (HashTable must have enough free buckets).
1527 */
1528#define ZEND_HASH_FILL_PACKED(ht) do { \
1529 HashTable *__fill_ht = (ht); \
1530 zval *__fill_val = __fill_ht->arPacked + __fill_ht->nNumUsed; \
1531 uint32_t __fill_idx = __fill_ht->nNumUsed; \
1532 ZEND_ASSERT(HT_IS_PACKED(__fill_ht));
1533
1534#define ZEND_HASH_FILL_GROW() do { \
1535 if (UNEXPECTED(__fill_idx >= __fill_ht->nTableSize)) { \
1536 __fill_ht->nNumOfElements += __fill_idx - __fill_ht->nNumUsed; \
1537 __fill_ht->nNumUsed = __fill_idx; \
1538 __fill_ht->nNextFreeElement = __fill_idx; \
1539 zend_hash_packed_grow(__fill_ht); \
1540 __fill_val = __fill_ht->arPacked + __fill_idx; \
1541 } \
1542 } while (0);
1543
1544#define ZEND_HASH_FILL_SET(_val) \
1545 ZVAL_COPY_VALUE(__fill_val, _val)
1546
1547#define ZEND_HASH_FILL_SET_NULL() \
1548 ZVAL_NULL(__fill_val)
1549
1550#define ZEND_HASH_FILL_SET_LONG(_val) \
1551 ZVAL_LONG(__fill_val, _val)
1552
1553#define ZEND_HASH_FILL_SET_DOUBLE(_val) \
1554 ZVAL_DOUBLE(__fill_val, _val)
1555
1556#define ZEND_HASH_FILL_SET_STR(_val) \
1557 ZVAL_STR(__fill_val, _val)
1558
1559#define ZEND_HASH_FILL_SET_STR_COPY(_val) \
1560 ZVAL_STR_COPY(__fill_val, _val)
1561
1562#define ZEND_HASH_FILL_SET_INTERNED_STR(_val) \
1563 ZVAL_INTERNED_STR(__fill_val, _val)
1564
1565#define ZEND_HASH_FILL_NEXT() do {\
1566 __fill_val++; \
1567 __fill_idx++; \
1568 } while (0)
1569
1570#define ZEND_HASH_FILL_ADD(_val) do { \
1571 ZEND_HASH_FILL_SET(_val); \
1572 ZEND_HASH_FILL_NEXT(); \
1573 } while (0)
1574
1575#define ZEND_HASH_FILL_FINISH() do { \
1576 __fill_ht->nNumOfElements += __fill_idx - __fill_ht->nNumUsed; \
1577 __fill_ht->nNumUsed = __fill_idx; \
1578 __fill_ht->nNextFreeElement = __fill_idx; \
1579 __fill_ht->nInternalPointer = 0; \
1580 } while (0)
1581
1582#define ZEND_HASH_FILL_END() \
1583 ZEND_HASH_FILL_FINISH(); \
1584 } while (0)
1585
1586/* Check if an array is a list */
1587static zend_always_inline bool zend_array_is_list(zend_array *array)
1588{
1589 zend_ulong expected_idx = 0;
1590 zend_ulong num_idx;
1591 zend_string* str_idx;
1592 /* Empty arrays are lists */
1593 if (zend_hash_num_elements(array) == 0) {
1594 return 1;
1595 }
1596
1597 /* Packed arrays are lists */
1598 if (HT_IS_PACKED(array)) {
1599 if (HT_IS_WITHOUT_HOLES(array)) {
1600 return 1;
1601 }
1602 /* Check if the list could theoretically be repacked */
1603 ZEND_HASH_PACKED_FOREACH_KEY(array, num_idx) {
1604 if (num_idx != expected_idx++) {
1605 return 0;
1606 }
1608 } else {
1609 /* Check if the list could theoretically be repacked */
1610 ZEND_HASH_MAP_FOREACH_KEY(array, num_idx, str_idx) {
1611 if (str_idx != NULL || num_idx != expected_idx++) {
1612 return 0;
1613 }
1615 }
1616
1617 return 1;
1618}
1619
1620
1621static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, bool interned)
1622{
1623 uint32_t idx = ht->nNumUsed++;
1624 uint32_t nIndex;
1625 Bucket *p = ht->arData + idx;
1626
1627 ZVAL_COPY_VALUE(&p->val, zv);
1628 if (!interned && !ZSTR_IS_INTERNED(key)) {
1630 zend_string_addref(key);
1631 zend_string_hash_val(key);
1632 }
1633 p->key = key;
1634 p->h = ZSTR_H(key);
1635 nIndex = (uint32_t)p->h | ht->nTableMask;
1636 Z_NEXT(p->val) = HT_HASH(ht, nIndex);
1637 HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
1638 ht->nNumOfElements++;
1639 return &p->val;
1640}
1641
1642static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *key, zval *zv)
1643{
1644 return _zend_hash_append_ex(ht, key, zv, 0);
1645}
1646
1647static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, bool interned)
1648{
1649 uint32_t idx = ht->nNumUsed++;
1650 uint32_t nIndex;
1651 Bucket *p = ht->arData + idx;
1652
1653 ZVAL_PTR(&p->val, ptr);
1654 if (!interned && !ZSTR_IS_INTERNED(key)) {
1656 zend_string_addref(key);
1657 zend_string_hash_val(key);
1658 }
1659 p->key = key;
1660 p->h = ZSTR_H(key);
1661 nIndex = (uint32_t)p->h | ht->nTableMask;
1662 Z_NEXT(p->val) = HT_HASH(ht, nIndex);
1663 HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
1664 ht->nNumOfElements++;
1665 return &p->val;
1666}
1667
1668static zend_always_inline zval *_zend_hash_append_ptr(HashTable *ht, zend_string *key, void *ptr)
1669{
1670 return _zend_hash_append_ptr_ex(ht, key, ptr, 0);
1671}
1672
1673static zend_always_inline void _zend_hash_append_ind(HashTable *ht, zend_string *key, zval *ptr)
1674{
1675 uint32_t idx = ht->nNumUsed++;
1676 uint32_t nIndex;
1677 Bucket *p = ht->arData + idx;
1678
1679 ZVAL_INDIRECT(&p->val, ptr);
1680 if (!ZSTR_IS_INTERNED(key)) {
1682 zend_string_addref(key);
1683 zend_string_hash_val(key);
1684 }
1685 p->key = key;
1686 p->h = ZSTR_H(key);
1687 nIndex = (uint32_t)p->h | ht->nTableMask;
1688 Z_NEXT(p->val) = HT_HASH(ht, nIndex);
1689 HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
1690 ht->nNumOfElements++;
1691}
1692
1693#endif /* ZEND_HASH_H */
size_t len
Definition apprentice.c:174
zval * zv
Definition ffi.c:3975
new_type size
Definition ffi.c:4365
void * ptr
Definition ffi.c:3814
memcpy(ptr1, ptr2, size)
HashTable * ht
Definition ffi.c:4838
buf start
Definition ffi.c:4687
ffi persistent
Definition ffi.c:3633
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
unsigned const char * pos
Definition php_ffi.h:52
collator_compare_func_t compare_func
Definition php_intl.h:49
unsigned char key[REFLECTION_KEY_LEN]
#define zend_hash_str_add(...)
Definition phpdbg.h:77
p
Definition session.c:1105
zend_ulong h
Definition zend_hash.h:95
zend_string * key
Definition zend_hash.h:96
$obj a
Definition test.php:84
#define pefree(ptr, persistent)
Definition zend_alloc.h:191
#define pemalloc(size, persistent)
Definition zend_alloc.h:189
struct _zval_struct zval
uint32_t num_args
zval * args
#define ZEND_API
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
Definition zend_hash.c:1727
ZEND_API void * zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len)
Definition zend_hash.c:90
ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, bool persistent)
Definition zend_hash.c:277
ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
Definition zend_hash.c:1869
ZEND_API void * zend_hash_find_ptr_lc(const HashTable *ht, zend_string *key)
Definition zend_hash.c:104
ZEND_API const HashTable zend_empty_array
Definition zend_hash.c:248
int(* apply_func_arg_t)(zval *pDest, void *argument)
Definition zend_hash.h:151
ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q)
Definition zend_hash.c:2952
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2744
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
Definition zend_hash.c:1727
ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func)
Definition zend_hash.c:2059
ZEND_API HashTable *ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate)
Definition zend_hash.c:3387
ZEND_API HashTable *ZEND_FASTCALL _zend_new_array_0(void)
Definition zend_hash.c:282
ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q)
Definition zend_hash.c:2933
ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht)
Definition zend_hash.c:346
ZEND_API HashTable *ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht)
Definition zend_hash.c:3334
ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len)
Definition zend_hash.c:1616
ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func)
Definition zend_hash.c:2192
ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *)
Definition zend_hash.c:2099
ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht)
Definition zend_hash.c:330
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h)
Definition zend_hash.c:1059
#define HASH_KEY_NON_EXISTENT
Definition zend_hash.h:31
ZEND_API zval *ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *key, size_t len, zval *pData)
Definition zend_hash.c:1052
ZEND_API HashTable * zend_array_to_list(HashTable *source)
Definition zend_hash.c:2526
ZEND_API uint32_t zend_array_count(HashTable *ht)
Definition zend_hash.c:476
struct _zend_hash_key zend_hash_key
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2773
ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht)
Definition zend_hash.c:1328
ZEND_API zval *ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag)
Definition zend_hash.c:3224
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData)
Definition zend_hash.c:1229
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1209
ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht)
Definition zend_hash.c:311
ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos)
Definition zend_hash.c:537
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos)
Definition zend_hash.c:2846
ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q)
Definition zend_hash.c:2961
ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht)
Definition zend_hash.c:1946
#define ZEND_HASH_MAP_FOREACH_KEY(ht, _h, _key)
Definition zend_hash.h:1354
#define HT_IS_WITHOUT_HOLES(ht)
Definition zend_hash.h:62
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData)
Definition zend_hash.c:1224
ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2733
ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed)
Definition zend_hash.c:322
ZEND_API void ZEND_FASTCALL zend_hash_iterators_advance(HashTable *ht, HashPosition step)
Definition zend_hash.c:724
ZEND_API zval *ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h)
Definition zend_hash.c:1234
bool(* merge_checker_func_t)(HashTable *target_ht, zval *source_data, zend_hash_key *hash_key, void *pParam)
Definition zend_hash.h:99
ZEND_API zval *ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2915
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1214
ZEND_API zval *ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *key, size_t len)
Definition zend_hash.c:1075
int(* apply_func_args_t)(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key)
Definition zend_hash.h:152
int(* bucket_compare_func_t)(Bucket *a, Bucket *b)
Definition zend_hash.h:299
ZEND_API zval *ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key)
Definition zend_hash.c:1012
ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht)
Definition zend_hash.c:1986
#define ZEND_HASH_PACKED_FOREACH_KEY(ht, _h)
Definition zend_hash.h:1495
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered)
Definition zend_hash.c:3197
ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv)
Definition zend_hash.c:1517
ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite)
Definition zend_hash.c:2547
ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p)
Definition zend_hash.c:1526
ZEND_API zval *ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1007
ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h)
Definition zend_hash.c:1692
ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2893
ZEND_API zval *ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key)
Definition zend_hash.c:2679
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *key, size_t len, zval *pData)
Definition zend_hash.c:1038
#define HASH_FLAG_STATIC_KEYS
Definition zend_hash.h:43
ZEND_API zval *ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1002
ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht)
Definition zend_hash.c:2015
ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
Definition zend_hash.c:2812
ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos)
Definition zend_hash.c:2870
ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTable *ht)
Definition zend_hash.c:608
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int,...)
Definition zend_hash.c:2137
ZEND_API zval *ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1219
ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht)
Definition zend_hash.c:374
ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed)
Definition zend_hash.c:396
ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len)
Definition zend_hash.c:1661
ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key)
Definition zend_hash.c:1566
#define HT_IS_PACKED(ht)
Definition zend_hash.h:59
ZEND_API zval *ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len)
Definition zend_hash.c:2689
ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx)
Definition zend_hash.c:3291
#define HT_HAS_ITERATORS(ht)
Definition zend_hash.h:76
ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor)
Definition zend_hash.c:2240
ZEND_API zval *ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *p, zend_string *key)
Definition zend_hash.c:1239
#define ZEND_HANDLE_NUMERIC_STR(key, length, idx)
Definition zend_hash.h:417
ZEND_API HashTable *ZEND_FASTCALL zend_new_pair(zval *val1, zval *val2)
Definition zend_hash.c:296
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber)
Definition zend_hash.c:3068
#define ZEND_HANDLE_NUMERIC(key, idx)
Definition zend_hash.h:420
ZEND_API zval *ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag)
Definition zend_hash.c:978
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
Definition zend_hash.c:1808
ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval *array)
Definition zend_hash.c:627
ZEND_API void ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam)
Definition zend_hash.c:2643
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *key, size_t len, zval *pData)
Definition zend_hash.c:1031
ZEND_API HashTable *ZEND_FASTCALL zend_array_dup(HashTable *source)
Definition zend_hash.c:2438
ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos_ex(const HashTable *ht, HashPosition pos)
Definition zend_hash.c:517
void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber)
Definition zend_hash.c:3074
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht)
Definition zend_hash.c:338
ZEND_API zval *ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key)
Definition zend_hash.c:1067
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
Definition zend_hash.c:1534
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
int(* apply_func_t)(zval *pDest)
Definition zend_hash.h:150
ZEND_API zval *ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h)
Definition zend_hash.c:2722
#define HT_FLAGS(ht)
Definition zend_hash.h:50
ZEND_API zval *ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:992
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
Definition zend_hash.c:2701
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterators_lower_pos(HashTable *ht, HashPosition start)
Definition zend_hash.c:694
ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed)
Definition zend_hash.c:435
ZEND_API void ZEND_FASTCALL zend_hash_iterator_del(uint32_t idx)
Definition zend_hash.c:649
ZEND_API zval *ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *key, size_t len, zval *pData, uint32_t flag)
Definition zend_hash.c:1017
ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht)
Definition zend_hash.c:512
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag)
Definition zend_hash.c:1191
ZEND_API void ZEND_FASTCALL _zend_hash_iterators_update(HashTable *ht, HashPosition from, HashPosition to)
Definition zend_hash.c:711
ZEND_API HashTable *ZEND_FASTCALL _zend_new_array(uint32_t size)
Definition zend_hash.c:289
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
struct _zend_string zend_string
#define END_EXTERN_C()
#define EXPECTED(condition)
#define zend_always_inline
#define ZEND_FASTCALL
#define ZEND_ASSERT(c)
#define UNEXPECTED(condition)
#define BEGIN_EXTERN_C()
#define ZEND_ASSUME(c)
struct _zend_array zend_array
ZEND_API void zend_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp)
Definition zend_sort.c:248
#define ZSTR_H(zstr)
Definition zend_string.h:70
#define ZSTR_IS_INTERNED(s)
Definition zend_string.h:84
int(* compare_func_t)(const void *, const void *)
Definition zend_types.h:104
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define HT_HASH(ht, idx)
Definition zend_types.h:463
#define IS_UNDEF
Definition zend_types.h:600
#define ZVAL_DEREF(z)
#define ZVAL_INDIRECT(z, v)
struct _zend_array HashTable
Definition zend_types.h:386
void(* sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t)
Definition zend_types.h:106
#define Z_NEXT(zval)
Definition zend_types.h:671
#define Z_PTR_P(zval_p)
void(* dtor_func_t)(zval *pDest)
Definition zend_types.h:107
#define GC_DELREF(p)
Definition zend_types.h:710
#define GC_FLAGS(p)
Definition zend_types.h:756
@ FAILURE
Definition zend_types.h:61
void(* copy_ctor_func_t)(zval *pElement)
Definition zend_types.h:108
uint32_t HashPosition
Definition zend_types.h:548
struct _Bucket Bucket
#define ZVAL_PTR(z, p)
#define Z_INDIRECT_P(zval_p)
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_ARRAY_IMMUTABLE
Definition zend_types.h:823
#define IS_ARRAY_PERSISTENT
Definition zend_types.h:824
#define IS_INDIRECT
Definition zend_types.h:623
#define ZVAL_COPY_VALUE(z, v)