-
Notifications
You must be signed in to change notification settings - Fork 136
/
php_runkit_hash.h
69 lines (63 loc) · 2.32 KB
/
php_runkit_hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group, (c) 2008-2015 Dmitry Zenovich |
+----------------------------------------------------------------------+
| This source file is subject to the new BSD license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.opensource.org/licenses/BSD-3-Clause |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Sara Golemon <[email protected]> |
| Modified by Dmitry Zenovich <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_RUNKIT_HASH_H
#define PHP_RUNKIT_HASH_H
/* {{{ php_runkit_hash_get_bucket */
inline static Bucket *php_runkit_hash_get_bucket(HashTable *ht, zend_hash_key *hash_key) {
Bucket *p = ht->arBuckets[hash_key->h & ht->nTableMask];
while (p) {
if ((p->arKey == hash_key->arKey) ||
((p->h == hash_key->h) && (p->nKeyLength == hash_key->nKeyLength) &&
!memcmp(p->arKey, hash_key->arKey, hash_key->nKeyLength))) {
return p;
}
p = p->pNext;
}
return NULL;
}
/* }}} */
/* {{{ php_runkit_hash_move_to_front */
inline static void php_runkit_hash_move_to_front(HashTable *ht, Bucket *p) {
if (!p) return;
/* Unlink from global DLList */
if (p->pListNext) {
p->pListNext->pListLast = p->pListLast;
}
if (p->pListLast) {
p->pListLast->pListNext = p->pListNext;
}
if (ht->pListTail == p) {
ht->pListTail = p->pListLast;
}
if (ht->pListHead == p) {
ht->pListHead = p->pListNext;
}
/* Relink at the front */
p->pListLast = NULL;
p->pListNext = ht->pListHead;
if (p->pListNext) {
p->pListNext->pListLast = p;
}
ht->pListHead = p;
if (!ht->pListTail) {
ht->pListTail = p;
}
}
/* }}} */
#endif